I have some controller code like this to update the workorder.wostatus_id field.
def changestatus
@workorder = Workorder.find(params[:id])
@workorder.update_attributes(params[:wostatus_id])
render nothing: true
end
And the coffee script that ends up executing changestatus:
receive: (event, ui) ->
alert $(ui.item).attr('change_url')
alert $(this).data('wostatus-id')
$.ajax
type: 'PUT'
url: "http://localhost:5000/workorders/13/changestatus"
data:
wostatus_id: 3
I have hard coded the url and wostatus_id while trying to get this working.
But, the following line isn’t getting the 3 from the coffee:
@workorder.update_attributes(params[:wostatus_id])
If I hard code the line to this, it works to update the wostatus to 3:
@workorder.update_attribute :wostatus_id, '4'
Thanks in advance!
This bit of your CoffeeScript:
Should give you a
paramsthat looks like this:So when you say:
you’re really saying:
and that doesn’t really make much sense. You need to give
update_attributesa key and a value: