【发布时间】:2016-03-04 11:20:29
【问题描述】:
所以我是 Rails 新手,目前正在 tutorialspoint 上阅读它的教程。到目前为止,我得到的是一个控制器和一个相应的视图,它是一个 erb 文件。这是视图的代码:
<% if @books.blank? %>
<p>There are not any books currently in the system.</p>
<% else %>
<p>These are the current books in our system</p>
<ul id = "books">
<% @books.each do |c| %>
<li><%= link_to c.title, {:action => 'show', :id => c.id} -%></li>
<% end %>
</ul>
<% end %>
<p><%= link_to "Add new Book", {:action => 'new' }%></p>
但是,当我尝试通过 localhost:3000 查看此内容时,
rails server
在 localhost:3000 后台运行 WEBrick 服务器的命令, 它不断将我引导到浏览器上的默认视图,该视图由服务器从以下路径呈现:
/Users/hassanali/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/railties-4.2.4/lib/rails/templates/rails/welcome/index.html.erb
而不是我的rails应用程序文件夹的视图文件夹中的实际视图..这是
/Users/hassanali/Desktop/library/app/views/book/list.html.erb
我多年来一直在尝试解决此问题,但无济于事。有谁知道我能做什么?
【问题讨论】:
标签: ruby-on-rails view controller