Created
August 11, 2012 01:05
-
-
Save pullmonkey/3319683 to your computer and use it in GitHub Desktop.
dynamic select models
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/models/artist.rb | |
class Artist < ActiveRecord::Base | |
belongs_to :genre | |
has_many :songs | |
attr_accessible :genre_id, :name, :genre | |
end | |
# app/models/genre.rb | |
class Genre < ActiveRecord::Base | |
attr_accessible :name | |
has_many :artists | |
has_many :songs, :through => :artists | |
end | |
# app/models/songs.rb | |
class Song < ActiveRecord::Base | |
belongs_to :artist | |
attr_accessible :artist_id, :title, :artist | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment