Forum: Ruby on Rails adding an attribute to a ActiveRecord::Base instance

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Felix M. (Guest)
on 2006-01-31 04:41
I have an instance of ActiveRecord::Base called Site.  Is it possible to
add attributes to that class in code, like so

class Site < ActiveRecord::Base
  belongs_to :user
  attr_accessor :type_site_boolop, :type_program_boolop, :books_only

I don't want those additional attributed in the DB.  The problem is that

@site =
@site.type_site_boolop = 'foo'

@site.attributes does not include type_site_boolop.  Any ideas?

Thanks again, I'm new too Rails and this forum has been most helpful

This topic is locked and can not be replied to.