我在 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.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 代码没有被评估而是被打印出来,但是语法对我来说看起来不错......有谁知道可能是什么问题?