rails new application name
A folder with the application name is created
rails server
rails generate controller home(Controller name) top(Action name)
When the top page is automatically created, three elements are created.
・ View Look at the part. Web html Stored in the views folder. File extension is erb
・ Controller Take an "action" in Ruby and return html to the browser. Returns the html with the same name as the action from the view folder with the same name on the controller. In other words, a mail carrier who receives a postcard and hands the postcard to the recipient.
・ Routing So to speak, it goes between the browser and the controller and manages the traffic. This url is the place to write your sorting to this controller. The routing is described by ʻurl => controller name # action name`.
In automatic creation, create the top page view + controller, Add routing for controller name # action name.
Example
<% posts.each do |post| %>
:
<% end %>
Also, if you want the code to be displayed in the browser, use <% =%>.
to be continued···
Recommended Posts