# Db connection within several applications (mountable engine)

**URL:** <https://www.ruby-forum.com/t/db-connection-within-several-applications-mountable-engine/220333>\
**Category:** Engines Development\
**Created:** [June 6, 2012, 9:11am UTC](https://www.ruby-forum.com/t/db-connection-within-several-applications-mountable-engine/220333 "2012-06-06T09:11:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [June 6, 2012, 9:11am UTC](https://www.ruby-forum.com/t/db-connection-within-several-applications-mountable-engine/220333/1 "2012-06-06T09:11:27Z")

</div>

Hi @ all,

we are developing an application consisting of several components. these  
components will be connected inside a mountable engine. our component  
has to interact with another component and we would like to connect two  
of the database tables with a has\_many and belongs\_to relation.

more details:

lets assume we have only two apps inside this mountable engine:  
festivalmanagement and usermanagement

inside the festivalmanagement exist a model ticket and we have the  
relation, that each user can have many tickets and each ticket belongs  
to one user. the ticket is a model of the festivalmanagement

what we would like to do is getting informations about the user by doing  
something like

id = @ticket.user.id  
name = ticket.user.name  
and so on…

so we want to have a direkt possibility to ask for the attributes of a  
user, which is not part of our app.

of course we can do a select statement by using the user id of a ticket  
(the user id is part of the database table tickets),  
but we thought that there should exist a more beautiful possibility.

is it enough just to add  
has\_many tickets  
to the user model and  
belongs\_to user  
to the ticket model?

hope someone can help me.

kind regards  
bernhard
