Nested Models Projects :has_many Tasks and Tasks :has_many Notes

Hello everyone,

I have 3 models that I am trying to link togheter:

resources :projects :shallow => true do
    resources :tasks do
      resources :notes
    end
  end

So most of it is working fine, but I can't figure out how to create
links between them. If I try this:

link_to task.name, project_tasks_path(@project, task.id)

I get the following URL:

/projects/2/tasks.3

If I try this:

link_to task.name, project_tasks_path(@project, @tasks)

The error is even more cryptic.

What I want is to have my /projects list all my projects. /projects/1
list all the tasks for that project and link to each specific task. /
projects/1/tasks/2 will display all the notes attached to the tasks,
and link to each note. /projects/1/tasks/2/notes/3 will be a specific
note.

Thanks.

Hi jesusOmar,
first of all, let me tell you that this question should go to rubyonrails-talk
group (http://groups.google.com/group/rubyonrails-talk). This one (rails-core)
is intended to other topics, related with the development of Rails itself.

As for your question, you have to write "task" in singular when you want to
link to specific task, and not to the tasks list.

  link_to task.name, project_task_path(@project, task)

You also should avoid using task.id, Rails does it for you, and maybe in the
future you'll link to the tasks using another param like a permalink.

Cheers!