Friday, January 7, 2011

[Rails] Re: assign values to attributes.

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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate