Hi,
I have two models which are related in a quite complicated way;
there's a User model, a Group model, and they're joined with
many-to-many link using GroupUser, so that a group has many
GroupUser-s and many User-s through GroupUser, and User has many
GroupUser-s and many Group-s through GroupUser. Also, User has one
Group designated as a main group, like this:
has_one :main_group, :through => :group_users, :source => :group,
:class_name => 'Group', :conditions => {'group_users.main' => true},
:dependent => :destroy
Now, I wanted a make a link to the current user's main group in the
navigation bar. So I wrote: <a:main_group /> - but I'm getting an
error about a nil object when evaluating nil.name. It seems that
instead of linking to /groups/<id>, it wants to create a link to
/users/<id>/groups/, because it thinks the main_group field is a
collection, and trips over this line in hobo_helper:
owner_name = obj.origin.class.reverse_reflection(obj.origin_attribute).name.to_s
And not only it's not a collection, but the User class doesn't have a
'group' field, because it has many groups. What is the best way for me
in this case to tell it to make a link directly to Group and don't
look into User at all?
Jakub Suder
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Hobo
Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/hobousers?hl=en
-~----------~----~----~----~------~----~------~--~---