A method that can be used when the login function is implemented in devise.
A record with id 1 has the same meaning as User.find (1).
You can get the value with current_user.name
etc.
To display different pages for each user in routing, use an unusual description method.
routes.rb
get 'users/:id' => 'users#show'
where method
One of Active Record
You can get an instance of a record that matches the condition taken as an argument in model.where (condition)
as an array type.
If you describe the conditions consecutively, you can get records that meet multiple conditions.
Sample.where('id < 3').where('user_id: 1')
Defining relationships between models makes it easy to call data across models.
Recommended Posts