โ Ruby on Rails learning pathRuby on Rails ยท Module 5 of 10
Views and templates
Views turn data into HTML with ERB templates.
๐ Key ideas
- Views live in app/views/<controller>/<action>.html.erb.
- <%= %> outputs a value; <% %> runs Ruby without output.
- Layouts (application.html.erb) wrap every page.
- Partials (_product.html.erb) reuse snippets with render.
- 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