Ruby on Rails Basic Memorandum

Ruby on Rails Memorandum of Understanding I'm studying the basics of Ruby on Rails, so I'll leave it as a memorandum for myself to remember.

What is Ruby on Rails in the first place A web application framework written in Ruby. The MVC (Model, View, Controller) model is adopted. In order to reduce the burden on the programmer, the necessary items are prepared in advance in the framework. There are two basic principles, "Don't Repeat Yourself" and "Convention over Cofiguration".

Create a new application
rails new application name

A folder with the application name is created

Start the server
rails server

Automatic creation of top page
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.

View file (extension .erb) The meaning of erb is Embedded Ruby. Use <%%> when embedding ruby code in a file.

Example


<% posts.each do |post|  %>
:
<% end %>

Also, if you want the code to be displayed in the browser, use <% =%>.

to be continued···

Recommended Posts

Ruby on Rails Basic Memorandum
Ruby on Rails basic learning ①
Basic knowledge of Ruby on Rails
Ruby on Rails Elementary
Ruby on Rails basics
Ruby On Rails Association
Rails new in Ruby on Rails ~ Memorandum until deployment 2
[Ruby on Rails] A memorandum of layout templates
Rails new in Ruby on Rails ~ Memorandum until deployment 1
Ruby on rails learning record -2020.10.03
Portfolio creation Ruby on Rails
Ruby on rails learning record -2020.10.04
[Ruby on Rails] Debug (binding.pry)
Ruby on rails learning record -2020.10.05
Ruby on rails learning record -2020.10.09
Ruby on Rails config configuration
Ruby on rails learning record-2020.10.07 ②
Ruby on rails learning record-2020.10.07 ①
Ruby on rails learning record -2020.10.06
Ruby on Rails validation summary
Rails memorandum
Ruby on Rails Overview (Beginner Summary)
[Ruby on Rails] Read try (: [],: key)
[Ruby on Rails] yarn install --check-files
Ruby on Rails variable, constant summary
Installing Ruby + Rails on Ubuntu 18.04 (rbenv)
[Ruby on Rails] Introduced paging function
Progate Ruby on Rails5 Looking Back
How to use Ruby on Rails
[Ruby on Rails] Add / Remove Columns
Ruby on Rails Japanese-English support i18n
(Ruby on Rails6) "Erase" posted content
[Ruby on Rails] CSV output function
Ruby on Rails 6.0 environment construction memo
[Ruby on Rails] What is Bcrypt?
[Ruby on Rails] Confirmation page creation
Memorandum (Ruby: Basic grammar: Iterative processing)
[Ruby on Rails] Comment function implementation
[Ruby on Rails] DM, chat function
[Ruby on Rails] Convenient helper method
[Ruby on Rails] Stop "looping until ..."
[Ruby on Rails] Introduction of initial data
[Ruby on Rails] Search function (not selected)
[Rails] Addition of Ruby On Rails comment function
[Ruby on Rails] Creating an inquiry form
Ruby basic terms
Ruby on Rails6 Practical Guide cp13 ~ cp15 [Memo]
[Ruby on Rails] View test with RSpec
Rails: 7 basic actions defined on the controller
[Ruby on Rails] How to use CarrierWave
[Ruby on Rails] 1 model CRUD (Routing Main)
Ruby on Rails installation method [Mac edition]
[Ruby on Rails] model, controller terminal command
Let's summarize "MVC" of Ruby on Rails
Ruby on Rails model creation / deletion command
[Ruby on Rails] About bundler (for beginners)
part of the syntax of ruby ​​on rails
Tailwind on Rails
Ruby on Rails6 Practical Guide cp7 ~ cp9 [Memo]
Rails tutorial memorandum 1
Ruby on Rails in Visual Studio Codespaces