trnc
trnc

Reputation: 21577

Rails POST params empty after submit?

i have a strange rails 3.2 problem. when i submit a form like this:

<%= form_for @job, :url => job_preview_path do |f| %>
<dl>
  <dt><%= f.label :job_title, "Job Titel" %></dt>
  <dd><%= f.text_field :job_title %></dd>
  <dt>Checkbox please!</dt>
  <dd><%= f.check_box :extra_featured %> </dd>
</dl>
<%= f.submit "Submit" %></p>
<% end %>

where the action route is defined as

match 'job/preview' => 'jobs#preview', :as => :job_preview, :via => :post

the values of the POST params stay empty after submit except for the check_box value. In the action in my controller after the submit, I reassigned the params to the model, so I can reuse the params for saving the entry.

def preview
  @job = Job.new(params[:job])
end

any advice on this strange behaviour? am i blind and don't see the bug?

Upvotes: 1

Views: 1440

Answers (1)

Yanhao
Yanhao

Reputation: 5294

Are you on Rails 3.2.3? One of the changes of Rails 3.2.3 to Active Record is that "Whitelist all attribute assignment by default." See [ANN] Rails 3.2.3 has been released!

Upvotes: 2

Related Questions