Loading...

WellRailed@googlegroups.com

[Prev] Thread [Next]  |  [Prev] Date [Next]

Re: [WellRailed] A question of style Matt Powell Thu Feb 02 16:09:42 2012

In that case, I'd append a '!' onto the method name, so you know it's going to 
have that effect:

    my_project.paid!

This specific example looks kind of state-machine-esque: I know some Rails 
state machine plugins use the '!' convention.


On 25/01/2012, at 10:01 AM, Henry Maddocks wrote:

> Something that has bothered me for a while is should model methods that set 
> attributes call save or should the caller do it?
> 
> ie. This...
> 
> class Project < ActiveRecord::Base
>   def paid
>     self.state = PAID
>     self.save
>   end
> 
> end
> 
> or this...
> 
> my_project.paid
> my_project.save
> 
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "WellRailed" 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/wellrailed?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"WellRailed" 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/wellrailed?hl=en.