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 %>
ID |
Project name |
Training name |
<%= link_to project.id, :action => "show", :id => projects.id %> | <%= project.name %> | <%= training.name %> |
Please help me out.
Thanks,