Forum: Rails Engines development db connection within several applications (mountable engine)

C8a350be7f4871892f549e68d96d3ee1?d=identicon&s=25 bernhard stoecker (stoecki)
on 2012-06-06 09:11
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
This topic is locked and can not be replied to.