Daniel Thompson Daniel Thompson - 14 days ago 4
AngularJS Question

Rails: parameters visible in console but not accessible as params

I am sending a get request to the url:

groups/:id.json


In my rails server console I see the following:

Processing by GroupsController#show as JSON
Parameters: {"id"=>"11"}


But I have no access to the params object in this show controller method. The following:

puts "puts params!"
puts params


Puts nothing to the console:

puts params!
#<ActionController::Parameters:0x007f7f9c482bf0>
Completed 500 Internal Server Error in 2ms (ActiveRecord: 0.0ms)

NoMethodError (undefined method `id' for #<ActionController::Parameters:0x007f7f9c482bf0>):


My rails project is serving as an API for an angular ui-router frontend and I am using Devise for user management. What could be preventing my params from showing up in this method?

Answer

Are you calling id as a method on params? It probably should be params[:id] instead of params.id