首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >comment_question去comment_questions

comment_question去comment_questions
EN

Stack Overflow用户
提问于 2013-10-28 00:46:27
回答 2查看 28关注 0票数 0

我有三种模式:帖子、评论和问题。我有一个链接,从我的帖子显示页面,应该去问题显示视图。相反,它会转到问题索引视图。

以下是耙的路线:

代码语言:javascript
复制
comment_question GET    /comments/:comment_id/questions/:id(.:format)        questions#show
comment_questions GET    /comments/:comment_id/questions(.:format)            questions#index

下面是posts的观点:

代码语言:javascript
复制
<%= 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 %>

谢谢你的帮助。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-10-28 00:52:39

如果帮助程序给您带来麻烦,您可以始终使用手动实现覆盖它们。

代码语言:javascript
复制
<a href="<%= url_for :controller => 'comments', :action => 'show', :comment_id => comment.id, :id => question.id %>"><%= @question.title %></a>
票数 0
EN

Stack Overflow用户

发布于 2013-10-28 00:52:13

尝试在您的question块中使用@question而不是@question

代码语言:javascript
复制
<%= link_to question.title, comment_question_path(comment, question) %>
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19625579

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档