ActiveRecord transient fields?

Discussion in 'Ruby' started by PerfectDayToChaseTornados, Mar 21, 2007.

  1. Hi All,

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

    Thanks :)

    --
    pdtct
    PerfectDayToChaseTornados, Mar 21, 2007
    #1
    1. Advertising

  2. 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/

    On Mar 21, 2007, at 4:35 PM, PerfectDayToChaseTornados wrote:

    > Hi All,
    >
    > Is it possible to have transient fields in a class that extends
    > ActiveRecord? If so how do I acheive it?
    >
    > Thanks :)
    >
    > --
    > pdtct
    >
    >
    >
    Duane Johnson, Mar 21, 2007
    #2
    1. Advertising

  3. Thanks Duane,

    that was exactly what I was asking :)

    --
    pdtct
    PerfectDayToChaseTornados, Mar 22, 2007
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?TmVsc29uIFAuIFZhcmdoZXNl?=

    Disable Session or Transient Cookies

    =?Utf-8?B?TmVsc29uIFAuIFZhcmdoZXNl?=, Jul 26, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    418
    =?Utf-8?B?TmVsc29uIFAuIFZhcmdoZXNl?=
    Jul 26, 2005
  2. Se-Jin Park
    Replies:
    1
    Views:
    4,569
    Chris Smith
    Nov 18, 2004
  3. Replies:
    3
    Views:
    20,900
    Roedy Green
    Jan 21, 2006
  4. Thomas Hawtin
    Replies:
    1
    Views:
    478
  5. smackedass
    Replies:
    5
    Views:
    491
    Daniel R. Tobias
    Aug 9, 2004
Loading...

Share This Page