Monday, 19 August 2013

link_to path ActiveRecord call

link_to path ActiveRecord call

I have users and projects, and I'm trying to create a link to the project
by searching for the project using an ActiveRecord call. This is my
link_to:
<%= link_to "Project ABC" User.first.projects.where('title' => 'Project
ABC') %>
I know that this is not in the routes.rb, so how would I be able to make
it so I can do something like this where I write a query to get the
project and then show it? Would I do something like:
<%= link_to "Project ABC"
show_project_path(User.first.projects.where('title' => 'Project ABC')) %>
If so, would I need anything special in my controller?

No comments:

Post a Comment