Request Processing
http://localhost:3000/posts/1
- Call method show in PostsController class passing the params [:id]
- The class' path is root_app/app/controllers/posts_controller.rb
- The show method will use ActiveRecord#find method to retrieve the post with id=1 from the database and assign to variable @post
- The controller will pass @post to the view (template file): root_app/app/views/posts/show.html.erb
Session
- Ex: session[ :current_user] = user_id
- flash is part of the session that is clear in each request
- Ex: flash[:notice] = 'Post was created'
Views
- To see the view files
- Go to root_app/app/views/posts
- The form is in the file _form.html.erb
- Embedded Ruby (ERb) is the most common templating framework
- Takes a .html.erb template file and transform as HTML
- <%= %> the code is assigned to the html file
- <% %> the code is only executed
- Layout
- The default layout is in root_app/views/layouts/application.html.erb
- Here contains all the look and feel for the site
Styles
- Go to root_app/app/assets/stylesheets where are the files
Comentarios
Publicar un comentario