UGH. Totally dumb.
My Role model had:
def id
end
Thus, overriding the accessor. Not sure how that got there - but,
problem solved.
On Jul 21, 7:28 am, bubba_baloo
<bubba_ba...-/E1597aS9LQAvxtiuMwx3w@public.gmane.org>
wrote:> Okay - so I''m finally making my first post after a couple of
months
> with RoR. Thanks for all the great information so far.
>
> I''m using mysql. I have a model called "Role".
I''m trying to retrieve
> the id for a record that has name = "Admin". From the Ruby
console:
>
> >> Role.find_by_name("Admin")
>
> => #<Role id: 233, created_at: "2008-07-21 12:55:27",
updated_at:
> "2008-07-21 12:55:27", name: "Admin">>>
Role.find_by_name("Admin").name
> => "Admin"
> >> Role.find_by_name("Admin").id
>
> => nil
>
> As you can see, Role.find_by_name("Admin") returns a record with
id:
> 233.
>
> So, why does Role.find_by_name("Admin").id return nil?
>
> If I go into MySQL Query Browser, I can do SELECT id FROM roles WHERE
> name = "Admin" and I get back "233" -
everything''s groovy.
>
> I''m sure I''m doing something dorky - apologies in
advance...
--~--~---------~--~----~------------~-------~--~----~
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@googlegroups.com
For more options, visit this group at
groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---