Ruby rails: views

From wikinotes

Views are the actual HTML websites, formatted using templating logic.

They are preprocessed using ruby eruby, and have access to all @instance_vars on the controller.

You may also be interested in ruby rails: view helpers.


Action/View docs
Action/View Form-helper docs


{project}/app/views/{controller}/{method}.html.erb view files (preprocessed html files)

Share data with Layout

<!-- view.html.erb -->
<% content_for(:user_list) do %>  <!-- block saved as ':user_list' -->
  <% ["alex", "courtney", "sam"].each do |user| %>
    <li><%= user %></li>
  <% end %>
<% end %>
<!-- layout.html.erb -->
    <%= yield :user_list %>  <!-- render 'user_list' defined above -->
    <%= yield %>             <!-- render view -->