[Rails Tutorial Chapter 5] Create a layout

navigation

All HTML can specify both class and id. These are just labels and are used when styling with CSS.

** The difference between a class and an id is that a class can be used multiple times within a page, but an id can only be used once. ** **

In the header tag below, three CSS classes, navbar, navba-fixed-top, and navbar-inverse, are given separated by spaces.


<header class = "navbar navbar-fixed-top navbar-inverse">

See the code below The .nav tag is responsible for clearly communicating the intent that ** the inside is a navigation link **. The nav, navbar-nav, and navbar-right classes attached to the .ul tag also have special meaning in Bootstrap.


<nav>
  <ul class="nav navbar-nav navbar-right">
    <li><%= link_to "Home",   '#' %></li>
    <li><%= link_to "Help",   '#' %></li>
    <li><%= link_to "Log in", '#' %></li>
  </ul>
</nav>

image_tag helper

This helper can set alt and width attributes using symbols. In the example below, the corresponding image file will be searched for in app / assets / images / through the asset pipeline.

<%= link_to image_tag("rails.svg", alt: "Rails logo", width: "200px"),
                      "https://rubyonrails.org/" %>

render method

You can pass the full path starting from app / views to the render method

<%= render "layouts/header"%>

Named route

Page name URL Named route
Home / root_path
About /about about_path
Help /help help_path
Contact /contact contact_path
Sign up /signup signup_path
Log in /login login_path

Recommended Posts

[Rails Tutorial Chapter 5] Create a layout
rails tutorial Chapter 1
rails tutorial Chapter 7
rails tutorial Chapter 5
rails tutorial Chapter 10
rails tutorial Chapter 9
rails tutorial Chapter 8
Rails Tutorial Chapter 5 Notes
Rails Tutorial Chapter 10 Notes
Rails Tutorial Chapter 3 Notes
Rails Tutorial Chapter 3 Learning
Rails Tutorial Memorandum (Chapter 3, 3.1)
Rails Tutorial Chapter 4 Notes
Rails Tutorial Chapter 4 Learning
Rails Tutorial Chapter 1 Learning
Rails Tutorial Chapter 2 Learning
Rails Tutorial Chapter 8 Notes
Rails Tutorial Memorandum (Chapter 3, 3.3.2)
[Rails tutorial] A memorandum of "Chapter 11 Account Activation"
[Rails Tutorial Chapter 4] Rails-flavored Ruby
[Rails Struggle/Rails Tutorial] Summary of Rails Tutorial Chapter 2
Tutorial to create a blog with Rails for beginners Part 1
Preparing to create a Rails application
rails tutorial
rails tutorial chapter 10 summary (for self-learning)
Create a new app in Rails
rails tutorial
rails tutorial
rails tutorial
Chewing Rails Tutorial [Chapter 2 Toy Application]
Tutorial to create a blog with Rails for beginners Part 2
rails tutorial
rails tutorial
rails tutorial
Rails Tutorial (4th Edition) Memo Chapter 6
Tutorial to create a blog with Rails for beginners Part 0
Rails Tutorial 6th Edition Learning Summary Chapter 10
Rails Tutorial 6th Edition Learning Summary Chapter 7
Rails Tutorial 6th Edition Learning Summary Chapter 4
[Rails6] Create a new app with Rails [Beginner]
Rails Tutorial 6th Edition Learning Summary Chapter 9
Rails Tutorial 6th Edition Learning Summary Chapter 6
[Rails withdrawal] Create a simple withdrawal function with rails
Rails Tutorial 6th Edition Learning Summary Chapter 5
Rails Tutorial 6th Edition Learning Summary Chapter 2
Rails Tutorial Chapter 0: Preliminary Basic Knowledge Learning 5
[Rails] Let's create a super simple Rails API
[rails] How to create a partial template
[Rails 5] Create a new app with Rails [Beginner]
Rails Tutorial 6th Edition Learning Summary Chapter 3
Rails Tutorial 6th Edition Learning Summary Chapter 8
Rails Tutorial Chapter 14 was completed, and it took a total of 155.5 hours.
Rails tutorial memorandum 1
Rails tutorial memorandum 2
Start Rails Tutorial
[Beginner] Rails Tutorial
A summary of only Rails tutorial setup related
[Rails Struggle/Rails Tutorial] What you learned in Rails Tutorial Chapter 6
[Rails] How to create a graph using lazy_high_charts
Rails Tutorial Chapter 1 From Zero to Deployment [Try]
Create a team chat with Rails Action Cable