Reputation: 701
I have a payments table and I want to be able to update all the date_of_payment fields simultaneously, i.e. with the same date.
In my view I have the following
<%= form_tag update_date_payments_path, :class => 'form_for_all', method: :put do %>
<%= date_select(:date_of_payment, :order => [:year, :month, :day] ) %>
<div class="actions">
<%= submit_tag 'Save' %>
</div>
<% end %>
And in my controller I have:
def update_date
Payment.update_all(params[:date_of_payment])
end
The error I'm getting is:
SQLite3::SQLException: no such column: {:order=>: UPDATE "payments" SET "{:order=>" = '--- - '':year, :month, :day'' - !ruby/hash:ActiveSupport::HashWithIndifferentAccess ! ''}(1i)'': ''2014'' ! ''}(2i)'': ''3'' ! ''}(3i)'': ''24'' '
I must confess that I'm a bit confused about what exactly this error is about. Is the code in my controller incorrect? Or is there something wrong with the form? As I said, I don't fully understand forms yet so any help at all would be greatly appreciated.
Upvotes: 1
Views: 493
Reputation: 8295
Check the syntax of update_all. I think you need something like:
Payment.update_all(date_of_payment: params[:date_of_payment])
Upvotes: 1