【发布时间】:2012-08-27 00:11:56
【问题描述】:
我在 Aptana Studio 3 中有一个 Rails 3 项目,其中有一个 html.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>
然后在嵌入式终端中,我运行 rails server,单击 Aptana 中的“使用 Firefox Server 运行”按钮,这将使用 Firefox 打开应用程序,并将我定向到此链接:http://127.0.0.1 :8020/library/app/views/book/book.html.erb
问题是我得到了这个输出:
<% if @books.blank? %>
There are not any books currently in the system.
<% else %>
These are the current books in our system
<% @books.each do |c| %>
<%= link_to c.title, {:action => 'show', :id => c.id} -%>
<% end %>
<% end %>
<%= link_to "Add new Book", {:action => 'new' }%>
似乎 ruby 代码没有被评估而是被打印出来,但是语法对我来说看起来没问题...有谁知道可能是什么问题?
【问题讨论】:
标签: html ruby-on-rails ruby embedded-ruby