我的index.html.haml页面是:
.panel-heading
%p.panel-title article
.panel-body.row
- @article.each do |article|
%h5.col-md-6.clearfix
= link_to article.title, article, style: "color: black";
%span.badge.pull-right
= article.comments.count
.info.text-muted
= link_to article.node.nodeName, topics_path(article.node.id)
•
= article.comments.last.created_at
路线:
articles GET /articles(.:format) articles#index
POST /articles(.:format) articles#create
new_article GET /articles/new(.:format) articles#new
edit_article GET /articles/:id/edit(.:format) articles#edit
article GET /articles/:id(.:format) articles#show
PATCH /articles/:id(.:format) articles#update
PUT /articles/:id(.:format) articles#update
DELETE /articles/:id(.:format) articles#destroy
topics GET /topics(.:format) topics#index
topic GET /topics/:id(.:format) topics#show
sites GET /sites(.:format) sites#index
jobs GET /jobs(.:format) jobs#index
notes GET /notes(.:format) notes#index
POST /notes(.:format) notes#create
new_note GET /notes/new(.:format) notes#new
edit_note GET /notes/:id/edit(.:format) notes#edit
note GET /notes/:id(.:format) notes#show
PATCH /notes/:id(.:format) notes#update
PUT /notes/:id(.:format) notes#update
DELETE /notes/:id(.:format) notes#destroy
root GET / articles#index
db Article
和Node
关联已经建立:
Article(id: integer, title: string, text: text,
created_at: datetime, updated_at: datetime, user_id: integer, node_id:
integer,article_img_file_name: string, article_img_content_type:
string, article_img_file_size: integer, article_img_updated_at: datetime)
Node(id: integer, nodeName: string, created_at: datetime,
updated_at: datetime)
the question is:
我点击a
标记显示:
http://localhost:3000/topics.8
试过了
= link_to article.node.nodeName, topics_path(article.node)
但没有意义
我可能会link_to
语法错误
有什么问题? 我怎么解决呢? 感谢
答案 0 :(得分:0)
应该是topic_path
而不是topics_path
= link_to article.node.nodeName, topic_path(article.node)
检查此路线
topic GET /topics/:id(.:format) topics#show