Ruby on rails learning record -2020.10.04

Rails design policy DRY:Don't Repeat Yourself Do not repeat the same work

CoC:Convention over Configuration Prioritize convention over configuration

Rails console Launch the Rails console ```rails console rails c ```

Exit Rails console

View data

Article.count


Show all data

Article.all


Display specific data

Article.find(1)


Substitute specific data into a variable and retrieve the column

article = Article.find(1)


article.content

Update column

article = Article.find(1)


article.content = "hello world"
article.save

Show all data

articles = Aricle.all


articles.each {|article| p article}

-What is migration? Mechanism for creating / modifying database tables

Generate a migration file to add columns rails generate migration AddCategoryToArticle category:string

Reflect database settings rails db:migrate

Cancel database settings rails db:rollback Post a new article in the Rails console article = Article.new article.feeling = "(^o^)" article.save

Recommended Posts

Ruby on rails learning record -2020.10.03
Ruby on rails learning record -2020.10.04
Ruby on rails learning record -2020.10.05
Ruby on rails learning record -2020.10.09
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 basic learning ①
Ruby on Rails Elementary
Ruby on Rails basics
[Ruby on Rails] About Active Record callbacks
Ruby On Rails Association
Portfolio creation Ruby on Rails
[Ruby on Rails] Debug (binding.pry)
Ruby on Rails config configuration
[Ruby on Rails] about has_secure_password
Commentary on partial! --Ruby on Rails
Cancel Ruby on Rails migration
Ruby on Rails validation summary
Ruby on Rails Basic Memorandum
Ruby learning 4
Ruby learning 5
Ruby on Rails5 Quick Learning Practice Guide 5.2 Compatible Chapter2
Ruby learning 3
Ruby learning 2
Ruby on Rails5 Quick Learning Practice Guide 5.2 Compatible Chapter3
Ruby learning 6
Ruby learning 1
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
Basic knowledge of Ruby on Rails
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
Ruby On Rails devise routing conflict
[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 record search, create if not find_or_create_by method
[Ruby on Rails] Introduction of initial data
[Ruby on Rails] Search function (not selected)
[Rails] Addition of Ruby On Rails comment function
Ruby Learning # 25 Comments
Ruby on Rails6 Practical Guide cp13 ~ cp15 [Memo]
Ruby Learning # 13 Arrays
[Ruby on Rails] View test with RSpec
[Ruby on Rails] How to use CarrierWave
[Ruby on Rails] Code check using Rubocop-airbnb
Ruby Learning # 1 Introduction
[Ruby on Rails] 1 model CRUD (Routing Main)