This time, I will briefly summarize how to operate the database using rails console.
① Add data to the table.
$rails console ///Below, in the command Post.In the content column with new"Hello World"Will be added. post = Post.new(content:"Hello World")
② Save the post.
$rails console post = Post.new(content:"Hello World") ///Below, save the post with the command. post.save
③ Get the data and refer to it.
$rails console post = Post.new(content:"Hello World") post.save ///Hereafter, the data is acquired. post = Post.first ///Visually confirm that the acquired data matches the data stored in the database. post.content
It's too simple to understand, but I'll improve the accuracy of the explanation in the future. .. Lol