Ruby on Rails Thursday, December 1, 2011

Vogon Primo wrote in post #1034547:
> Hi all,
>
> In a sample project, I have a nested resource called ticket, and parent
> resource called project.
>
> rake routes:
> ...
> project_tickets GET /projects/:project_id/tickets(.:format)
> {:action=>"index", :controller=>"tickets"}
>
> POST /projects/:project_id/tickets(.:format)
> {:action=>"create", :controller=>"tickets"}
> ...
>
> but when I go to http://127.0.0.1:3000/projects/7/tickets/ I have this
> routing error:
>
> No route matches {:action=>"show", :controller=>"tickets",
> :project_id=>nil, :id=>#<Project id: 7,
> name: "bla...bla", created_at: "2011-11-29 14:39:51",
> updated_at: "2011-11-29 14:39:51">}
>
> It invokes the show action and not the index action. Why?

Ok, I am sorry but, it was my error . In index.html.erb I had

<%=link_to ticket.title,project_ticket_path(@project,@path)%>

this, on the contrary of what is present in some online RoR examples,
doesn't work for me. I have changed it with

<%=link_to ticket.title,[@project,@path] %>

--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment