2015-06-28 11:58:53 +00:00
|
|
|
class Book < ActiveRecord::Base
|
2015-06-28 12:59:37 +00:00
|
|
|
establish_connection Rails.configuration.database_configuration["calibre"]
|
2015-06-28 14:09:16 +00:00
|
|
|
|
|
|
|
has_and_belongs_to_many :authors,
|
|
|
|
join_table: "books_authors_link",
|
|
|
|
foreign_key: "book",
|
|
|
|
association_foreign_key: "author"
|
2015-06-28 14:39:18 +00:00
|
|
|
has_and_belongs_to_many :tags,
|
|
|
|
join_table: "books_tags_link",
|
|
|
|
foreign_key: "book",
|
|
|
|
association_foreign_key: "tag"
|
|
|
|
has_and_belongs_to_many :languages,
|
|
|
|
join_table: "books_languages_link",
|
|
|
|
foreign_key: "book",
|
|
|
|
association_foreign_key: "lang_code"
|
|
|
|
|
|
|
|
has_one :book_publisher_link, foreign_key: "book"
|
|
|
|
has_one :publisher, through: :book_publisher_link
|
|
|
|
|
2015-06-28 14:09:16 +00:00
|
|
|
has_one :book_serie_link, foreign_key: "book"
|
|
|
|
has_one :serie, through: :book_serie_link
|
2015-06-28 11:58:53 +00:00
|
|
|
end
|