โ† Ruby on Rails learning path
Ruby on Rails ยท Module 5 of 10

Views and templates

Views turn data into HTML with ERB templates.

๐Ÿ“– Key ideas

  1. Views live in app/views/<controller>/<action>.html.erb.
  2. <%= %> outputs a value; <% %> runs Ruby without output.
  3. Layouts (application.html.erb) wrap every page.
  4. Partials (_product.html.erb) reuse snippets with render.
  5. Helpers like link_to and form_with build HTML safely.
๐Ÿ’ก Real-life example: Like a printed form with blanks: the template is the form, and ERB fills in each student's details.
ERBEmbedded Ruby templates
LayoutShared page wrapper
PartialReusable view snippet
link_toHelper that builds a link