RailsCasts Pro episodes are now free!

Learn more or hide this

Recent Comments

Avatar

@avadhbsd Use omniauth-facebook gem version 1.4.0. According to many comments elsewhere. 1.4.0 is the "most/last stable version". Some folks mentioned that certain versions of rails conflict with the omniauth-facebook gem also. See this link for more: http://stackoverflow.com/questions/13425757/rails-facebook-login-error-with-omniauth-facebook-omniauthstrategiesoauth2

Avatar

Hey I am having a similar issue, no idea on next steps could you help?

Avatar

So all that "complex" logic goes in the js files, and routing is done through angular. Does all of this make the rails functionality for these tasks redundant? How do you resolve or use both simultaneously?

Avatar

@Jen Did you ever figure out why you were getting 500 internal server error when hitting /auth/facebook? I'm experiencing the same issue. Any help is appreciated!

Avatar

Wouldn't it be better if we put this Cart#paypal_url method into a helper (eg. CartsHelper). Then, we don't have to pass the return_url around.

I don't really see how generating a paypal url is the responsibility of the Cart model. And the url is only being referenced in the view anyway. I think the helper is a better place for this kind of thing.

Avatar

I ran into the same method. I have a project model with many conflicts through project_conflicts. I want to isolate conflicts to the user that generates them though.

My solution was to add an after_create callback on the join model that updated the newly generated conflict object with the project's user_id. This seems to be working since the join belongs to both and is created last.

Avatar

Same issue for me.

Edit:

It is a relatively simple fix for rails 4 due to the lack of attr_accessible.

application_controller.rb
class ApplicationController < ActionController::Base
  # Prevent CSRF attacks by raising an exception.
  # For APIs, you may want to use :null_session instead.
  protect_from_forgery with: :exception

  # Devise Stuff
  before_filter :configure_permitted_parameters, if: :devise_controller?

  protected

  def configure_permitted_parameters
    devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:email, :password, :password_confirmation, :username) }
  end
  # End Devise Stuff
end
Avatar

I watched the video and followed all the instruction of Fnordmetric railscast.

install redis

redis-server /usr/local/etc/redis.conf

Redis is working fine on my local(Ubuntu 12.04)

gem install fnordmetric

Installed successfully.

Created new fnordmetric.rb file

When I run ruby fnordmetric.rb on terminal

$ ruby fnordmetric.rb
./fnordmetric.rb:3: uninitialized constant FnordMetric (NameError)
from fnordmetric.rb:1:in `require'
from fnordmetric.rb:1

I am getting above error.

Please help me to fix this issue and get it working

Thanks in advance

Avatar

hi i am using rails 4.1.2, ruby 2.0.0
I upgraded the application form rails 3.2.14 to rails 4.1.2

ActiveModel::ForbiddenAttributesError in AAAAAImportsController#create
ActiveModel::ForbiddenAttributesError

ruby
  def import_params
    params.require(:aaaaa_import).permit(:file)
  end
ruby
@aaaaa_import = AaaaaImport.new(import_params)

in my controller and removed attr_accessible in model

Avatar

in savon 2 that will be
client = Savon.client(wsdl: "http://www.webservicex.net/uszip.asmx?WSDL", basic_auth: ["user", "secret"])

Avatar

If someone like me is wondering about how the example lines are in savon 2, they are like this.

client = Savon.client(wsdl: "http://www.webservicex.net/uszip.asmx?WSDL")
client.operations
client.call(:get_info_by_zip, message: { "USZip" => "90210" })

Avatar

I have the very same problem. Did you find a solution?

Avatar

Changing Authentication Fields is not working with Rails 4 and Devise. May be it's due to attr_accessible. What should I replace it with and why?

Avatar

Hi Ryan

Just wanted to say thank you very much for an excellent video. Hope you are doing well and that you soon have enough energy to return to railscast.

Avatar

so years later in rails 4, is Kaminari still better, cleaner, and frequently updated as will_paginate?

Avatar

This seems to be the only reference I can find on the net to run thor through zeus. However, I'm slightly unsure what you mean. What's thor.json? I've had a ganders through thor's docs and can't find a reference to it. And what's custom_plan.rb? Is that one of your own commands?

Avatar

hi everyone I am rails beginner I need some modifications in the calendar how do change this calendar with link that when I click an any date it has to show the corresponding day below the calendar.....please share your ideas...

Avatar

If you need VPS just for stage you can use https://teatro.io/ instead.

Avatar

Adding separate env for staging looks like not a good idea, because it will differ from real production. BTW you can use special service for stages https://teatro.io/ that will automate the whole process.

Avatar

There is a syntax error in the file index.html.erb

<% form_for is give it should be
<%= form_for

Avatar

With rails4 you must specify the parameters that are being saved.

CommentsContrller.rb
    @comment = @article.comments.create!(comment_params)
    redirect_to @article, :notice => "Comment Created!"
  end   
  
  private
     def comment_params
        params.require(:comment).permit(:name, :content)
     end
Avatar
ruby
 respond_to do |format|
                        format.html { render action: request.path[1..-1], status: request.path[1..-1] }
                        format.json { render json: {status: request.path[1..-1], error: @exception.message}, status: request.path[1..-1]}
                end
Avatar
ruby
                respond_to do |format|
                        format.html { render action: request.path[1..-1], status: 404 }
                        format.json { render json: {status: request.path[1..-1], error: @exception.message}, status: 404}
                end

Using status respond to the error is better for others system knows what is happeing

Avatar

You could also check out my gem 'attr_searchable'

https://github.com/mrkamel/attr_searchable

which adds support for search engine like queries to ActiveRecord models and can exploit fulltext indices for mysql/postgres.

Avatar

Did you get this working? I am seeing the same issue.

Avatar

I've been getting "undefined method `fog_credentials=' for CarrierWave::Uploader::Base:Class" every time I tried to run rake db:reset or rails s. Could anyone please help?

Avatar

You are correct, update_all is called once for each faq item, which results in a separate query for each faq item. The performance gain is because update_all updates the order field in a single query as opposed to first loading the model then doing an update in a separate query.

This still works in Rails 4 by the way, but the syntax is a little different:

ruby
Faq.where(id: id).update_all(position: index+1)
Avatar

Just what I've thought while watching this episode and what I was wondering of. Thanks, Mario

Avatar

Chock full of goodness. This pulled together a lot of concepts. One of my favs so far!

Avatar

I believe you will still need to run rails server in another terminal window

Avatar

I keep getting a Missing Template error when I hit send. I'm using the chatter-before straight out of the box. Any clue what's going on?

Template is missing

Missing template messages/create, application/create with {:handlers=>[:erb, :builder, :coffee], :formats=>[:html], :locale=>[:en, :en]}. Searched in: * "/Users/stevenspiel/sites/chatter/chatter-before/app/views"

Avatar

+1

Works like a charm! Thanks!

Avatar

How can I send this pdf to various email address. Please please help me.

Avatar

Have anybody tried to test this with Capybara?

I keep getting JSON invalid when testing it (using AJAX approach). Works fine in development though....

Avatar

Please note the new ActiveModel::Model available in Rails 4 which makes it much easier to create a tableless model. In fact, the code shown in this screencast for the model doesn't actually work fully with Rails 4 presumably because of this change (at least it didn't work for me). For info, see: http://blog.plataformatec.com.br/2012/03/barebone-models-to-use-with-actionpack-in-rails-4-0/

Avatar

I'm brand new to Rails and am having an issue with my routing once I fill out the Sign up form and click Save User.

I'm getting a Routing Error that reads "No route matches [POST] "/signup" "

rake routes returns this:

ruby
      Prefix Verb   URI Pattern                  Controller#Action
      logout GET    /logout(.:format)            sessions#destroy
       login GET    /login(.:format)             sessions#new
      signup GET    /signup(.:format)            users#new
       users GET    /users(.:format)             users#index
             POST   /users(.:format)             users#create
    new_user GET    /users/new(.:format)         users#new
   edit_user GET    /users/:id/edit(.:format)    users#edit
        user GET    /users/:id(.:format)         users#show
             PATCH  /users/:id(.:format)         users#update
             PUT    /users/:id(.:format)         users#update
             DELETE /users/:id(.:format)         users#destroy
    sessions GET    /sessions(.:format)          sessions#index
             POST   /sessions(.:format)          sessions#create
 new_session GET    /sessions/new(.:format)      sessions#new
edit_session GET    /sessions/:id/edit(.:format) sessions#edit
     session GET    /sessions/:id(.:format)      sessions#show
             PATCH  /sessions/:id(.:format)      sessions#update
             PUT    /sessions/:id(.:format)      sessions#update
             DELETE /sessions/:id(.:format)      sessions#destroy
      secret GET    /secret(.:format)            home#secret
  home_index GET    /home/index(.:format)        home#index
    home_new GET    /home/new(.:format)          home#new
        root GET    /                            home#index

What am I missing?

Avatar

I would add

ruby
entry.$update()

after "entry.winner = false" to persist the action

Avatar

Instead of curl -I I advise curl -v. The curl -I could change the server behaviour like in case of grape based apis.

Avatar

Would it be possible to use this with nested items?

IE I have a view setup with many Todo Lists and I'd like to be able to add Todo Items under those lists dynamically. (basically how a todo list works at Basecamp)

I have the proper associations taken care of, so I can add Todo Items to Todo Lists via the HTML form, but can't figure out how to pass the todo_list_id through jquery to use the remote option.

Avatar

+1 , this happened to me..good point !

Avatar

HI Karthik,

I have the same issue, did you figure out why its happening ? when i put "production.foo.com" in url...it shows the same message as yours. Please help !

Avatar

THIS GEM DOES NOT WORK WITH RAILS 4. Don't even try it. The employee who made it formerly worked for Twitter, then left Twitter, and no one else on the team is interested in supporting it. Recommend the Thumbs Up gem. https://github.com/bouchard/thumbs_up

Avatar

Is it possible to change the default line separator from newline '\n' or '\r\n' to some other character, e.g '|' while parsing csv