NoMethodError (undefined method `symbolize_keys!' for #<ActionController::Parameters:0x00007f964a22d7f0>): - ruby-on-rails

We recently updated rails application to Rails 5.0 and are getting this error
NoMethodError (undefined method `symbolize_keys!' for #<ActionController::Parameters:0x00007f964a22d7f0>):
if we have the below parameter
<ActionController::Parameters {"first_name"=>"first name", "middle_name"=>"", "last_name"=>"lname", "email"=>"name#domain.com", "id"=>"138755"} permitted: false>
accessing by the both ways works
params[:first_name]
params['first_name']
Any help on why the error is happening and how to fix it would be really great.
Thanks.

Related

Rails Hartl Tutorial: Unable to Fix NoMethodError in PasswordResetsTest

I am getting the following NoMethodError even though my database table has the reset_sent_at column and User.last.reset_sent_at is not nil.
I will appreciate if anyone can help in fixing this error. Thanks.
PasswordResetsTest#test_password_resets:
NoMethodError: undefined method `reset_sent_at=' for #<User:0x00007f8e34164210>
Did you mean? reset_token=
app/models/user.rb:66:in `create_reset_digest'
app/controllers/password_resets_controller.rb:14:in `create'
test/integration/password_resets_test.rb:19:in `block in <class:PasswordResetsTest>'

Rails & Heroku - Find User By Lowercase Username

in rails development environment I find a user by its lowercased username in the routes.
For example:
#user = User.find_by_username(params[:id].downcase)
This piece of code runs perfectly fine in development, but when this code runs in production (Heroku) I get
ActionView::Template::Error (undefined method `username' for nil:NilClass):
Is there a go around for this issue?
By the end I've used
User.where('lower(username) = ?', params[:id]).first
Sorry for the consfusion and the incertitude :)

How to access "extra" Hashie in omniauth-facebook callback

In a Rails app I had the following code updating the user's profile from their Facebook profile
self.update_attributes( :location => request.env["omniauth.auth"].extra.raw_info.location.name )
I'm in the process of updating Rail and gems, and now this line is failing.
NoMethodError (undefined method `name' for nil:NilClass):
Looking at the output, I see
...
extra: !map:Hashie::Mash
raw_info: !map:Hashie::Mash
...
How can I access attributes within this Hashie?

configure warden rails

I started my rails app and suddenly got the following error
/.rvm/gems/ruby-1.9.3-p194/gems/devise-2.1.2/lib/devise.rb:406:in `configure_warden!': undefined method `failure_app=' for nil:NilClass (NoMethodError)
devise.rb line 406 has:
warden_config.failure_app = Devise::Delegator.new
I cannot figure out the problem, how do i go about this?

undefined method `parent' for nil:NilClass

I'm getting this strange error using Rails 3.0.2.
ActionView::Template::Error (undefined method `parent' for nil:NilClass):
app/controllers/channels_controller.rb:19:in `index'
This is the controller, and line 19 is the respond_with(#channels) block.
Where do I start to search for errors?
class ChannelsController < ApplicationController
before_filter :set_default_client
respond_to :html, :xml
def index
if params[:cache_set]
#channels = Channel.active.find_all_by_id(params[:cache_set])
else
#channels = Channel.active.find_all_by_id(cookies[:channels].split(','))
end
respond_with(#channels)
end
end
This is the full error:
ActionView::Template::Error (undefined method `parent' for nil:NilClass):
app/controllers/channels_controller.rb:19:in `index'
Rendered /Users/linus/.rvm/gems/ruby-1.8.7-p330/gems/actionpack-3.0.2/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.3ms)
Rendered /Users/linus/.rvm/gems/ruby-1.8.7-p330/gems/actionpack-3.0.2/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (19.8ms)
Rendered /Users/linus/.rvm/gems/ruby-1.8.7-p330/gems/actionpack-3.0.2/lib/action_dispatch/middleware/templates/rescues/template_error.erb within rescues/layout (28.6ms)
I'm using Ruby 1.8.7 with Rails 3.0.2.
I've also, just in case, tried Rails 3.0.7 and 3.0.0.
Are you in any case using HAML?
I just bumped into this as well and my colleague (who is not on Stackoverflow yet) found out that it was due to multiline comments in the view template
-#
= helper_method_1
= helper_method_2
I solved the problem by changing HAML version from 3.1.x to 3.0.24.
My new Gemfile looks like this.
gem "rails", "3.0.2"
gem "haml", "3.0.24"
gem "compass", "0.10.6"
It looks like HAML-edge has fixed this problem.
I expect the next release of HAML after 3.1.1 to resolve this.

Resources