(Ruby on Rails6) Creating data in a table

Preface

I thought it would be convenient to set the data in the table, so I will record the data setting in one or more tables. In both cases, save is performed at the end. Don't forget! An error will occur when retrieving the data !!

Creating data in a table

One data setting

command


rails console

Variable 1=Model name.new(Column name: "Contents")
test1 = Test.new(description: "smple_text")

Variable 1.save
test1.save

Multiple data settings

Enter , </ strong> in the previous command.

command


rails console

Variable 1=Model name.new(Column name: "Contents",Column name: "Contents")
test1 = Test.new(description: "smple_text",title: "smple_title" )

Variable 1.save
test1.save

Afterword

Thank you for reading this far. That's all for creating the data in the table. Please make use of it.

My link

Also, there is a link on Twitter / Portfolio, so if you are interested, Please connect. I would be very happy to have friends who can share programming learning.

Twitter Portfolio Github

Recommended Posts

(Ruby on Rails6) Creating data in a table
A series of flow of table creation → record creation, deletion → table deletion in Ruby on Rails
Ruby on Rails Japanese-English support i18n
Difficulties in building a Ruby on Rails environment (Windows 10) (SQLite3)
How to display a graph in Ruby on Rails (LazyHighChart)
Explanation of Ruby on rails for beginners ③ ~ Creating a database ~
Apply CSS to a specific View in Ruby on Rails
[Ruby on Rails] Introduction of initial data
Ruby on Rails in Visual Studio Codespaces
Beginners create portfolio in Ruby on Rails
Change from SQLite3 to PostgreSQL in a new Ruby on Rails project
Escape processing when creating a URL in Ruby
How to create a query using variables in GraphQL [Using Ruby on Rails]
Recommendation of Service class in Ruby on Rails
Rails new in Ruby on Rails ~ Memorandum until deployment 2
Introducing Rspec, a Ruby on Rails test framework
Ruby on Rails Elementary
[Ruby on Rails] A memorandum of layout templates
Ruby on Rails basics
Rails new in Ruby on Rails ~ Memorandum until deployment 1
Ruby On Rails Association
[Ruby on Rails] How to install Bootstrap in Rails
I made a portfolio with Ruby On Rails
How to make a unique combination of data in the rails intermediate table
How to clear all data in a particular table
[Introduction] Try to create a Ruby on Rails application
[Ruby on Rails Tutorial] Error in the test in Chapter 3
Build a Ruby on Rails development environment on AWS Cloud9
[Ruby On Rails] How to reset DB in Heroku
[Ruby on Rails] Post image preview function in refile
How to store Rakuten API data in a table
Explanation of Ruby on rails for beginners ② ~ Creating links ~
A memorandum about table data types and commands (Rails)
Ruby on rails learning record -2020.10.03
Portfolio creation Ruby on Rails
[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
Creating a calendar using Ruby
Ruby on Rails basic learning ①
[Rails] Creating a search box
[Ruby on Rails] about has_secure_password
Ruby on rails learning record-2020.10.07 ②
Multiplication in a Ruby array
Commentary on partial! --Ruby on Rails
Post a video on rails
Cancel Ruby on Rails migration
Ruby on rails learning record -2020.10.06
Ruby on Rails validation summary
Ruby on Rails Basic Memorandum
Ruby on Rails Incorrect string value error resolution when posting a form in Japanese
Definitely useful! Debug code for development in Ruby on Rails
[Ruby on Rails] Add a column with a foreign key constraint
[Ruby on Rails] Quickly display the page title in the browser
A note about the seed function of Ruby on Rails
[Ruby On Rails] How to search and save the data of the parent table from the child table
Ruby on Rails Overview (Beginner Summary)
Sorting hashes in a Ruby array
[Ruby on Rails] Read try (: [],: key)
[Ruby on Rails] yarn install --check-files