# Newbie :: multiple database

**URL:** <https://www.ruby-forum.com/t/newbie-multiple-database/92431>\
**Category:** Rails\
**Created:** [April 19, 2007, 1:24pm UTC](https://www.ruby-forum.com/t/newbie-multiple-database/92431 "2007-04-19T13:24:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![aveo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/aeb1de/32.png) [@aveo](https://www.ruby-forum.com/u/aveo)\
**Post date:** [April 19, 2007, 1:24pm UTC](https://www.ruby-forum.com/t/newbie-multiple-database/92431/1 "2007-04-19T13:24:42Z")

</div>

Hi all,

# I’ve a three simple table, resource

resource.id  
resource.name  
resource.contact

# project

project.id  
project.name  
project.resource\_id (id from resource table)

and

# training

training.id  
training.name  
training.resource\_id (id from resource table)

I want to display list of projects and trainings that only belong to  
particular resource.

#in project Controller  
def proj  
@resource =Resource.find(params[:id], :include =\> :projects)  
end

So it is showing projects associated with resource, But how can show  
trainings associated with resource on same page.

I was trying something like

#### 

@train = Training.find(@params[“id”])

#### in proj

But doesnot work. Do I need to create association for this?

my  
#proj.rhtml

# Projects of Resource: \<%= @resource.name %\>
 \<% @resource.projects.each do |project| %\> \<% end %\>

| 

_ **ID** _

 | 

_ **Project name** _

 | 

_ **Training name** _

 |
| \<%= link\_to project.id, :action =\> "show", :id =\> projects.id %\> | \<%= project.name %\> | \<%= training.name %\> |

Please help me out.

Thanks,

---

<div class="post-metadata">

**Author:** ![aveo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/aeb1de/32.png) [@aveo](https://www.ruby-forum.com/u/aveo)\
**Post date:** [April 19, 2007, 3:21pm UTC](https://www.ruby-forum.com/t/newbie-multiple-database/92431/2 "2007-04-19T15:21:48Z")

</div>

@resource =Resource.find(params[:id], :include =\>[:projects, :trainings]

As long as your associations are set in the models, this will work.

class Resource \< ActiveRecord::base  
has\_many :trainings  
has\_many :projects

end

That will work.

Rails has an api at [http://api.rubyonrails.com](http://api.rubyonrails.com) where this is all  
documented.  
You should make sure to give that a look if you have additional  
questions.
