ruby - "No explicit conversion of Symbol into String" for new records in rails 4.0.1 (only) -


after rails 4 upgrade, trying create new record of activerecord classes gives

no explicit conversion of symbol string 

for example, here links links_params method

def link_params   params.require(:link)   .permit(:url_address, :group_id, :alt_text, :version_number,    :position, :content_date, :verified_date) # line 157 end  # line 118 is: @link = link.new(link_params) 

but get

typeerror (no implicit conversion of symbol string):   app/controllers/links_controller.rb:157:in `link_params'   app/controllers/links_controller.rb:118:in `create'  error occurred while loading following files: link  parameters:  {"utf8"=>"✓",  "authenticity_token"=>"0fqftx2ejcio+r+rm97lf15+id4b452n+dbuunxal9u=",  "link"=>{"url_address"=>"http://www.google.com",  "alt_text"=>"",  "version_number"=>"",  "group_id"=>"49",  "content_date"=>"08/18/2014"},  "commit"=>"save"} 

i'm not sure how happened, looks params object hash... , not actioncontroller::parameters object. when params hash:

params = {"utf8"=>"✓", "authenticity_token"=>"0fqftx2ejcio+r+rm97lf15+id4b452n+dbuunxal9u=", "link"=>{"url_address"=>"http://www.google.com", "alt_text"=>"", "version_number"=>"", "group_id"=>"49", "content_date"=>"08/18/2014"}, "commit"=>"save"}  params.require(:link) => typeerror: no implicit conversion of symbol string  params.class => hash 

but if it's actioncontroller::parameters object

params2 = actioncontroller::parameters.new({"utf8"=>"✓", "authenticity_token"=>"0fqftx2ejcio+r+rm97lf15+id4b452n+dbuunxal9u=", "link"=>{"url_address"=>"http://www.google.com", "alt_text"=>"", "version_number"=>"", "group_id"=>"49", "content_date"=>"08/18/2014"}, "commit"=>"save"})  params2.require(:link) =>{"url_address"=>"http://www.google.com", "alt_text"=>"", "version_number"=>"", "group_id"=>"49", "content_date"=>"08/18/2014"}   params2.class =>actioncontroller::parameters 

are doing params before link_params gets hold of it?

edit: according api docs, strong params available in rails 4.0.2. if you're using earlier version, have stick rails 3 attr_accessible


Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -