-
-
Save lexmag/3178573 to your computer and use it in GitHub Desktop.
Namespaced 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
% rails g model Hotel | |
% rails g model Hotel::Translation # or hotel/translation |
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
class Hotel < ActiveRecord::Base | |
has_many :translations, class_name: 'Hotel::Translation' | |
end |
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
class Hotel::Translation < ActiveRecord::Base | |
belongs_to :hotel | |
end |
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
> Hotel.first.translations | |
> Hotel::Translation.first.hotel |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment