Skip to content

Instantly share code, notes, and snippets.

en = Book.create(:locale => 'en')
ca = en.translate('ca')
reader = Reader.create(:locale => 'en')
en.readers << reader
assert_equal [reader], en.readers
assert_not_equal [reader], ca.readers
assert_equal 'ca', ca.readers.first.locale
assert_equal 2, Reader.count
en = Book.create(:locale => 'en')
ca = en.translate('ca')
reader = Reader.create(:locale => 'en')
ca.readers << reader
assert_equal [reader], ca.readers
assert_equal [reader], en.readers
assert_equal 1, Reader.count
Book.with_genres_in('Thriller')
# also with multiple parameters
Book.with_genres_in('Biography', 'Travel')
class Book
categorized_with :genres, :size => :many
end
def self.filtered_search(filters = {}, options = {})
# ...
case filter
when :genres
category_conditions_for :genres, value
end
end
Book.filtered_search(:genres => 'Thriller')
has_many :books, :translation_shared => true
has_many :books, :translation_shared => true
has_many :authors, :translation_shared => true
belongs_to :file, :translation_shared => true
has_one :biography, :translation_shared => true
share_translations_for :books, :authors, :file, :biography
has_many :books, :translation_shared => true
media_attachment :images, :translation_shared => true
# now equivalent to
has_many :books
media_attachment :images
share_translations_for :books, :images
rake ubiquo:foreach:pull