Making AR attriibutes private


#1

Hi,

Can anyone tell me the syntax to make AR attributes private so that they
can only be set through an object’s constructor?

I want do something like this, where item_id and rated_by are private
and set only through the constructor:

Schema as of Mon Mar 06 21:22:59 BRT 2006 (schema version 15)

id :integer(11) not null

item_id :integer(11) default(0), not null

rated_by :integer(11) default(0), not null

created_on :datetime not null

updated_on :datetime not null

class Wow < ActiveRecord::Base
belongs_to :item
validates_presence_of :item_id, :rated_by

def initialize(item, user)
super()
self.item_id = item.id
self.rated_by = user.id
end

end

How do I make item_id and rated_by private and still accessible
internally by the constructor?

Thanks,

Tim C.
removed_email_address@domain.invalid