Hi! I’m developing a music sharing website. I have an album model that I want to contain a list of Tracks. I’m running into an issue where I don’t know if the data exists or is connected to the model or?
Although you don’t say how you produced this output, it looks like the result of Object#inspect, which will display the attributes of the base object but not any associations. This is normal behavior.
How I produced it was using rails console setting @album = Album.first and typing @album gave me the first output. After that I used @album.tracks and it gave me the second output.
This answer sounds right. Is there a command to show attributes as well as associations?
Basically your relation is declared in the model class, probably in ‘app/models/album.rb’, and it should have something like:
has_many :tracks, dependent: :destroy
That is what indicates the relation in your model, but the tracks per se are not store in an attribute of the class. You will not find a field tracks in the db table of your Album model (schema.rb)