I'm a little confused on how hidden form fields work in Rails, like for example I have two hidden fields in my form like so:
(for a polymorphic model for commenting)
<%= form_for [commentable, commentable.comments.build], :remote => 'true' do |form| %>
<%= hidden_field "resource", commentable.class.to_s.downcase %>
<%= hidden_field "resource_id", commentable.id %>
<%= form.text_area :body %>
<%= submit_tag 'Post comment' %>
<% end %>
But so this works 开发者_运维知识库fine and what not, but the params that I receive in my controller are like this:
"resource"=>"photos", "resource_id"=>{"174"=>""}
Why is my resource_id
param a hash too?
<%= hidden_field "resource_id", commentable.id.keys[0] %>
A better question would be, where and how are you assigning the id?
This doesn't answer the question directly, but... Take out the resource_id and look in your params in the log file, I think the id is already passed in the url because of the path you provide in the form_for call
精彩评论