initializing variables in ActiveRecord's classes

Posted by Hadi on Stack Overflow See other posts from Stack Overflow or by Hadi
Published on 2010-06-03T07:38:37Z Indexed on 2010/06/03 7:44 UTC
Read the original article Hit count: 325

Filed under:
|
|

How to initialize variables in ActiveRecord class? Variables here is the variables that are outside the scope of database

such as:

class Product
  attr_accessor :used
end

I want to initially assign @used initially to false, later if some person access the product, i will change @used to true

First i thought of putting @used=false in initialize method, but it does not get called.

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about ruby