# Question about relations

**URL:** <https://www.ruby-forum.com/t/question-about-relations/104315>\
**Category:** Rails\
**Created:** [May 16, 2007, 6:15pm UTC](https://www.ruby-forum.com/t/question-about-relations/104315 "2007-05-16T18:15:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![laurent](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/ce7236/32.png) [@laurent](https://www.ruby-forum.com/u/laurent)\
**Post date:** [May 16, 2007, 6:15pm UTC](https://www.ruby-forum.com/t/question-about-relations/104315/1 "2007-05-16T18:15:50Z")

</div>

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
