Some Rails Notes
.erb files
You can block HTML within ruby code.
<% 3.times do -%>
Ho!<br />
<% end %>
Merry Christmas!
Loop which in turn sets a variable:
<% 3.downto(1) do |count| -%>
<%= count %>…<br />
<% end %>
Lift off!
Escape HTML using h()
Email: <%= h(“Ann & Bill <frazers@isp.email>”) %>
Symbols and linking to Actions in Rails
Think of symbols in rails as “the thing named”.
So in a link for example <%= link_to “goodbye”, :action => “goodbye” %>
The thing named :action => “goodbye”
Looping through objects
<% for file in @files %>
file name is: <%= file %>
<% end %>OR
<% @files.each do |file| %>
file name is: <%= file %>
<% end %>
No comments yet