Ruby on Rails
Saturday, July 25, 2015
On Saturday, July 25, 2015 at 5:46:47 PM UTC+1, donz wrote:
The payload is a string because the app was generated using rails-api new myapp rather than rails new myapp. I am using rails-api because I am doing all interactions with the rails app in json. Using rails-api eliminates all of the rendering code and keeps heroku happier from a memory usage point of view.Do you know why the payload is a string rather than a hash ?What format is the data being posted in (form data,json, xml etc ?) It seems to me that your first problem is to solve this - even if you were to solve the strong parameters bit presumably your code is expecting params[:user] to be a hash
Fred
When I generate the exact same app using just plain rails new myapp it responds correctly to the incoming json with its own json results. In other words, params(:user) returns an object which responds to the permits method with rails but the same code returns a string with rails-api, raising the NoMethod exception.
I have found many "solutions" to this on the web (so I am not the first to encounter it), but for some reason none of them work for me. The explanation below gives more technical details (this one came from StackOverflow):
I still think you have a more fundamental problem. With or without strong_parameters, params[:user] should be a hash (and the rails-api gem looks like it loads strong parameters for you anyway). How are you making your post requests to your app?
Fred
-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/8591d477-92f2-4601-a0b8-a55c4081736e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment