On Apr 18, 12:49 pm, Greg Ma <[email protected]> wrote: > Hi, > > I can't find how do i created a getter and setter property for a non db > property. what i have done isnt working, i have a cnt mass assign error. > The mass assignment error is probably not related to this (at least not what you have shown)
> Here is what i've done: > attr_accessor :creator_is_participant What this does is create a getter and setter method of that name that stores its data in @creator_is_participant - if you're going to redefine both of those methods then you don't need that > > def creator_is_participant=(participe) > if participe == true > @participe = true > else > @participe = false > end > end This may have unintended consequences further down the line because it puts you at odds with what the ruby world considers to be true/false: nil and false are false, everything else has the truth value true Fred -- 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.

