Is it possible to to freeze a single attribute of an ActiveRecord (Rails 2.3.5). Hopefully in a way that isn''t deprecated in 2.3.8 or 3.0. TIA, Jeffrey -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Sep 9, 2:11 am, "Jeffrey L. Taylor" <r...-f/t7CGFWhwGcvWdFBKKxig@public.gmane.org> wrote:> Is it possible to to freeze a single attribute of an ActiveRecord (Rails > 2.3.5). Hopefully in a way that isn''t deprecated in 2.3.8 or 3.0. >attr_readonly ? Fred -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
@frederick i think he want to freeze a feature of and old rails version so he doesnt need to migrate his app On Thu, Sep 9, 2010 at 3:52 AM, Frederick Cheung <frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > On Sep 9, 2:11 am, "Jeffrey L. Taylor" <r...-f/t7CGFWhwGcvWdFBKKxig@public.gmane.org> wrote: > > Is it possible to to freeze a single attribute of an ActiveRecord (Rails > > 2.3.5). Hopefully in a way that isn''t deprecated in 2.3.8 or 3.0. > > > attr_readonly ? > > Fred > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
and still be able to use the new version of rails On Thu, Sep 9, 2010 at 7:38 AM, radhames brito <rbritom-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> @frederick > i think he want to freeze a feature of and old rails version so he doesnt > need to migrate his app > > > On Thu, Sep 9, 2010 at 3:52 AM, Frederick Cheung < > frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> >> >> On Sep 9, 2:11 am, "Jeffrey L. Taylor" <r...-f/t7CGFWhwGcvWdFBKKxig@public.gmane.org> wrote: >> > Is it possible to to freeze a single attribute of an ActiveRecord (Rails >> > 2.3.5). Hopefully in a way that isn''t deprecated in 2.3.8 or 3.0. >> > >> attr_readonly ? >> >> Fred >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Ruby on Rails: Talk" group. >> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> >> . >> For more options, visit this group at >> http://groups.google.com/group/rubyonrails-talk?hl=en. >> >> >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Quoting Frederick Cheung <frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:> > > On Sep 9, 2:11 am, "Jeffrey L. Taylor" <r...-f/t7CGFWhwGcvWdFBKKxig@public.gmane.org> wrote: > > Is it possible to to freeze a single attribute of an ActiveRecord (Rails > > 2.3.5). Hopefully in a way that isn''t deprecated in 2.3.8 or 3.0. > > > attr_readonly ? >Not quite what I wanted, but interesting none the less. I wanted an attribute that could not be modified in memory. From the documentation, this allows it to be modified, but won''t write the modified value to the DB. I think a way to do this is create the value on object instantiation, freeze it, and then assign it to the attribute. It''s a calculated value in an ActiveRecord that has associated objects. I want to make sure, one of the associated objects doesn''t modify the value. No write accessor just prevents changing the attribute to refer to a different object. It does not prevent modifying the assigned object. Thanks, Jeffrey -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Sep 10, 1:30 am, "Jeffrey L. Taylor" <r...-f/t7CGFWhwGcvWdFBKKxig@public.gmane.org> wrote:> Quoting Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: > > > > > On Sep 9, 2:11 am, "Jeffrey L. Taylor" <r...-f/t7CGFWhwGcvWdFBKKxig@public.gmane.org> wrote: > > > Is it possible to to freeze a single attribute of an ActiveRecord (Rails > > > 2.3.5). Hopefully in a way that isn''t deprecated in 2.3.8 or 3.0. > > > attr_readonly ? > > Not quite what I wanted, but interesting none the less. I wanted an > attribute that could not be modified in memory. From the documentation, this > allows it to be modified, but won''t write the modified value to the DB. > > I think a way to do this is create the value on object instantiation, freeze > it, and then assign it to the attribute. It''s a calculated value in an > ActiveRecord that has associated objects. I want to make sure, one of the > associated objects doesn''t modify the value. No write accessor just prevents > changing the attribute to refer to a different object. It does not prevent > modifying the assigned object. >You could overwrite the read accessor to call freeze! for you. Fred> Thanks, > Jeffrey-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.