mrg mrg - 9 months ago 45
Ruby Question

How to store data to database in Rails

I have a controller named 'register' with action 'store'. The 'store' method have two instance variable called '@name' and '@age'. And
I have a model file named 'person.rb'. Now, How I share the instance variable in controller to model. And how to store data stored in database.


To store it in the database you will need to

Person.create(age: @age, name: @name)