# What is the best way to format a large has_many through line?

This question is about code style.

I have this line in one of my models:

has_many :owning_artists, :through => :artist_tracks, :source => :artist, :conditions => { :artist_tracks => { :artistic_role_id => 1, :another_memeber => 42 } }


What is the best way to break this up on multiple lines, and indented of course, and what would it would look like?

I'd love to hear a more general recommendation/guideline for how to break up and indent nested hashes too.

This is what I would do:

has_many :owning_artists, {
:through => :artist_tracks,
:source => :artist,
:conditions => {
:artist_tracks => {
:artistic_role_id => 1,
:another_memeber => 42
}
}
}

• Can't really add to this other than to say that if the artist_tracks hash had more than one member I would break those on to individual lines as well, indented accordingly.
– Robin Fisher
Feb 26 '13 at 15:56