Reputation: 23
In rails 4 usually updating a nested attributes we do:
and in rails 3? should user params.require?
def sent
@user.update_attributes(order_params)
def order_params
params.require(:user).permit( order_attributes: [:track_number])
end
end
class User < ActiveRecord::Base
has_many :orders
end
Upvotes: 0
Views: 155
Reputation: 1680
You can use this gem strong parameter
in rails 3
Link: strong parameter gem.
and If you do not want to add separate gem for this you can allow the parameter by attr_accessible
. (This is default and ideal way of allowing parameters).
Edit:
To allow nested attributes in attr_accessible
you have to use this accepts_nested_attributes_for
Upvotes: 1