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