mrg mrg - 1 year ago 85
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.

Answer Source

To store it in the database you will need to

Person.create(age: @age, name: @name)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download