I'm working with a pre-defined database, datamapper and rails3.
Previously we've used a php front end to manage the system.

In the process of migrating to a RoR application, I've run into issues
with my many to many relationships.

I've been following [this tutorial][1] to try and get things working
but still cannot get it sorted.

Relationships are as follows:

Radcheck have and belong to many Groups through Radusergroup
Groups have and belong to many Radcheck through Radusergroup

I have this in my models:

    class Radcheck
      include DataMapper::Resource

      has n, :radgroups, :model => 'Group', :child_key =>
[:groupname], :parent_key => [:username], :through => :radusergroup

    end

--

    class Group
      include DataMapper::Resource

      has n, :radusers, :model => 'Radcheck', :child_key =>
[:groupname], :parent_key => [:name], :through => :radusergroup

    end

--

    class Radusergroup

      include DataMapper::Resource

      belongs_to :radusers, :model => 'Radcheck', :child_key =>
[:username]
      belongs_to :radgroups, :model => 'Group', :child_key =>
[:groupname]

    end


My radusergroup table looks like this:

    +-------------+------------+----------+
    | username    | groupname  | priority |
    +-------------+------------+----------+
    | silverxxxx  | silverxxxx |        1 |
    | shushxx     | 30-minutes |        0 |
    | jennybluntx | silverxxxx |        1 |
    +-------------+------------+----------+

However, when I start the server, I'm presented with this error:

/usr/local/lib/ruby/gems/1.9.1/gems/dm-core-1.2.0/lib/dm-core/
associations/many_to_many.rb:101:in `via': No relationships named
radusers or raduser in GroupRadcheck
(DataMapper::UnknownRelationshipError)

I thought this method would define the table properly but can see it's
still trying to call it GroupRadcheck


  [1]: 
http://invalidlogic.com/2010/01/27/named-many-to-many-relationships-in-datamapper/

-- 
You received this message because you are subscribed to the Google Groups 
"DataMapper" 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/datamapper?hl=en.

Reply via email to