Getter and Setter with non DB property

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.

Here is what i've done:
attr_accessor :creator_is_participant

  def creator_is_participant
    @participe
  end

  def creator_is_participant=(participe)
    if participe == true
      @participe = true
    else
      @participe = false
    end
  end

Greg

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