Testing ActiveRecord associations in the Rails console

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 #activerecord #testing https://rubyonrails.ba/single/testing-activerecord-associations-in-the-rails-console

Nezir Zahirovic

Contractor Ruby On Rails (8+ years) / MCPD .Net / C# / Asp.Net / CSS / SQL / (11 years)

related articles