Skip to content

Instantly share code, notes, and snippets.

@oren
Created May 3, 2010 05:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oren/387801 to your computer and use it in GitHub Desktop.
Save oren/387801 to your computer and use it in GitHub Desktop.
class TranslationValue < ActiveRecord::Base
has_many :key_values
has_many :translation_keys, :through => :key_values
end
class TranslationKey < ActiveRecord::Base
has_many :key_values
has_many :translation_values, :through => :key_values
end
class KeyValue < ActiveRecord::Base
end
tv = TranslationValue.create(:text => 'test', :language_id => 1)
tk = TranslationKey.create(:name => 'key1')
how to add key model to value model and visa versa?
tv.translation_key_ids
NameError: uninitialized constant TranslationValue::KeyValue
TranslationValue has_many :translation_keys, :through => :key_values
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment