Testing ActiveRecord associations in the Rails console
21-Jan-2019 2151
When building a new Rails app, you usually get to create several models with all kinds of associations between them (see more in the documentation).The usual steps after creating the app would be as follows:Create the ActiveRecord models.Build the ActiveRecord associations within the models (e.g. belongs_to, has_many, has_many: through etc.)Create the db tables and migrations.Check the schema to verify that the tables have the correct structure.Test the ActiveRecord models associations.This last step is the one we will cover in this tutorial. It is a fairly simple task once you understand the basics, and it can save you a lot of trouble later on when building up on the functionality of your app.
Testing ActiveRecord associations in the Rails console #ruby #rubydeveloper #rubyonrails #Testing #ActiveRecord #associations #Rails #console #activerecord #testing https://rubyonrails.ba/link/testing-activerecord-associations-in-the-rails-console