IMHO, your first attempt, update attributes in model, is the best
practice because model is where you keep attention of your data.
Anyway, to save your data in the controller:
def create
@supplier = Supplier.new(params[:supplier])
@supplier.durc_expiry_date = @supplier.durc_issue_date + 90.days
@suplier.save
.....
Or maybe, if you want rescue errors:
def create
@supplier = Supplier.new(params[:supplier])
@supplier.durc_expiry_date = @supplier.durc_issue_date + 90.days
if @suplier.save
do stuff
else
do other stuff
end
.....
Regards,
Giorgio
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.