0
我想教自己Ruby和Ruby on Rails。有人可以给我这个代码的一些简单的指针从http://guides.rubyonrails.org/getting_started.html获取Ruby语法直接
<%= form_for(@post) do |f| %>
<% if @post.errors.any? %>
<div id="errorExplanation">
<h2><%= pluralize(@post.errors.count, "error") %> prohibited
this post from being saved:</h2>
<ul>
<% @post.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="field">
<%= f.label :name %><br />
<%= f.text_field :name %>
</div>
<div class="field">
<%= f.label :title %><br />
<%= f.text_field :title %>
</div>
<div class="field">
<%= f.label :content %><br />
<%= f.text_area :content %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
问题:
- 有时代码使用
<%
,有时使用<%=
。我什么时候使用其中任何一种? @
在Ruby中的含义是什么,何时被使用?- 除了HTML,还有Ruby代码,还是Ruby on Rails引入的一些新的代码/语法?
http://stackoverflow.com/questions/11247480/what-is-the-difference-between-and-in-ruby-on-rails – 2013-02-19 21:49:15
和http://stackoverflow.com/questions/14319347/变数在红宝石轨道 – 2013-02-19 21:50:09
所有这些问题都回答了无数次。你介意使用谷歌或stackoverflow的搜索功能? – 2013-02-19 21:50:52