Newbie :: multiple database

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,

@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 where this is all
documented.
You should make sure to give that a look if you have additional
questions.