ActiveRecord transient fields?

  • Thread starter PerfectDayToChaseTornados
  • Start date
P

PerfectDayToChaseTornados

Hi All,

Is it possible to have transient fields in a class that extends
ActiveRecord? If so how do I acheive it?

Thanks :)
 
D

Duane Johnson

I think you're asking if it's possible to add attributes to AR-
derived classes. Yes:

class Person < ActiveRecord::Base
attr_accessor :my_transient_field
end

p = Person.new
p.my_transient_field = 1
# the value of my_transient_field will not be stored in the database

Duane Johnson
http://blog.inquirylabs.com/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top