Skip to content

Instantly share code, notes, and snippets.

@lexmag
Created July 25, 2012 20:45
Show Gist options
  • Save lexmag/3178573 to your computer and use it in GitHub Desktop.
Save lexmag/3178573 to your computer and use it in GitHub Desktop.
Namespaced models
% rails g model Hotel
% rails g model Hotel::Translation # or hotel/translation
class Hotel < ActiveRecord::Base
has_many :translations, class_name: 'Hotel::Translation'
end
class Hotel::Translation < ActiveRecord::Base
belongs_to :hotel
end
> 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