I have created the attr_accessors for everything I need but still when I try to get some of the attributes, it returns nil. I know they have a value since I can check the database with external program. For example: object = Object.find(id) object.id # works object.name # works object.read_by_default # doesnt work I''ve been having this on and off now and it''s driving me crazy. I must be doing something very slightly but fundamentally wrong. Any ideas? I''m a bit self-conscious about showing the actual code but it''s as simple as my example above. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
RoR newbie wrote:> I have created the attr_accessors for everything I need but still when > I try to get some of the attributes, it returns nil. I know they have a > value since I can check the database with external program. > > For example: > > object = Object.find(id) > object.id # works > object.name # works > object.read_by_default # doesnt work > > I''ve been having this on and off now and it''s driving me crazy. I must > be doing something very slightly but fundamentally wrong. Any ideas? I''m > a bit self-conscious about showing the actual code but it''s as simple as > my example above.You don''t need attr_access for an ActiveRecord::Base object, AR already gives that to you for free. By adding your own accessors you''re actually stopping the AR stuff from having. By the way, not showing your code is a bit silly: it just makes it a lot harder for the folks trying to help you to understand what''s happening. Fred -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
RoR newbie wrote:> I have created the attr_accessors for everything I need but still when > I try to get some of the attributes, it returns nil. I know they have a > value since I can check the database with external program. > > For example: > > object = Object.find(id) > object.id # works > object.name # works > object.read_by_default # doesnt workI assume read_by_default is a boolean. Are you sure you''re testing that this attribute is not nil, and not that the value is true? Chris --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---