I'm currently using ActiveRecord single table inheritance.
How can I cast one of my models from type A to B? They have the same parent.
ActiveRecord::Base indicates that the ActiveRecord class or module has a static inner class called Base that you're extending.
In Active Record, objects carry both persistent data and behavior which operates on that data. Active Record takes the opinion that ensuring data access logic as part of the object will educate users of that object on how to write to and read from the database.
What is ActiveRecord? ActiveRecord is an ORM. It's a layer of Ruby code that runs between your database and your logic code. When you need to make changes to the database, you'll write Ruby code, and then run "migrations" which makes the actual changes to the database.
#becomes
is what you are looking for:
http://api.rubyonrails.org/classes/ActiveRecord/Persistence.html#method-i-becomes
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With