我有三种模式:帖子、评论和问题。我有一个链接,从我的帖子显示页面,应该去问题显示视图。相反,它会转到问题索引视图。
以下是耙的路线:
comment_question GET /comments/:comment_id/questions/:id(.:format) questions#show
comment_questions GET /comments/:comment_id/questions(.:format) questions#index下面是posts的观点:
<%= div_for(comment) do %>
<% comment.questions.select(:title).order('created_at desc').limit(3).each do |question| %>
<%= link_to (question.title), comment_question_path(comment, @question) %>
<% end %>
<% end %>谢谢你的帮助。
发布于 2013-10-28 00:52:39
如果帮助程序给您带来麻烦,您可以始终使用手动实现覆盖它们。
<a href="<%= url_for :controller => 'comments', :action => 'show', :comment_id => comment.id, :id => question.id %>"><%= @question.title %></a>发布于 2013-10-28 00:52:13
尝试在您的question块中使用@question而不是@question:
<%= link_to question.title, comment_question_path(comment, question) %>https://stackoverflow.com/questions/19625579
复制相似问题