Forum: Ruby on Rails Question about relations

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
B1415e872f86d771167c48a0832f583b?d=identicon&s=25 Laurent (Guest)
on 2007-05-16 18:15
(Received via mailing list)
Hi

We get a little problem to do some relations between to Models :

First we have to Tables :

Roles :
id (pk)
..
c_type_role

Role_Action_Relations :
id (pk)
...
c_type_role_id

For one class of role (Roles.c_type_role) we can have many associated
permitted actions (Role_Action_Relations)

We would like to have a relation OneToMany between Roles and
Role_Action_Relations : the foreign key Roles.C_TYPE_ROLE would be
linked to Role_Action_Relations.c_type_role_id

As our columns don't follow the convention for RoR, we've designed the
Models like this :

class Role < ...
has_many :role_action_relation,
  :finder_sql => ' here the sql statement to get children rows from
Role_Action_Relations'
end

class Role_Action_Relation < ...

end

My question is : Is there a simpler method to do this relation,
because we encounter some problems with the finder_sql option.

Thanks

Laurent
This topic is locked and can not be replied to.