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

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
B098106f5cffacdbb4566d7195dcdd08?d=identicon&s=25 Felix M. (fmcbst)
on 2006-01-31 03: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
given

@site = Site.new
@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
already!

Felix
This topic is locked and can not be replied to.