I am trying to create an empty model, populate it and then add it to the database.
I am looking through Google for the syntax for instantiating a simple model that I can set fields in, but there does not seem to be much documentation for that.
Is that just not the intended useage pattern? If it is, how can I just create the empty model?
Thanks!
An ActiveRecord model works based on what fields it’s related table has in your db. If you have no db yet you have no fields. The usage pattern goes like this:
You now have a model associated with a clients table that has a string attribute called name.
Now in your controller you can use this by
Which will create the model object, set the name, and persist it to the db