【发布时间】:2014-12-07 16:23:49
【问题描述】:
我正在尝试在索引页面中创建一个超链接,但它没有显示,也没有给出任何错误。这是我的 index.html.erb 代码。
<h1> Listing articles </h1>
<% link_to 'New article', new_article_path %> <---- Everything works perfectly except this doesnt show anything
<table>
<tr>
<th>Title</th>
<th>Textssss</th>
<tr>
<% @articles.each do |article| %>
<tr>
<td><%= article.title %> </td>
<td><%= article.text %> </td>
</tr>
<% end %>
</table>
我检查了我的路线,我认为它们也很好。
Prefix Verb URI Pattern Controller#Action
welcome_index GET /welcome/index(.:format) welcome#index
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
root GET / welcome#index
我可以从本地主机手动访问文章/新文章,但我认为这不是问题。 任何帮助表示赞赏..
【问题讨论】:
-
将
=添加到link_to。<%= link_to 'New article', new_article_path %>并阅读ERB -
谢谢老兄,清理了很多东西..
标签: ruby-on-rails ruby