I have an association:
an author has many books;
and a book has many authors;
I need to use :through option(through a table named 'relations',has two column named 'left_id' (used as author_id) and 'right_id' (used ad book_id);
class Relation < ActiveRecord::Base
belongs_to :books
belongs_to :authors
end
class Author < ActiveRecord::Base
has_many :relations, :foreign_key => 'left_id'
has_many :books, :through => :relations
end
In the console:
> author = Author.new
> author.books
# => Error: no such column: relations.book_id
So, how could I specific the 'book_id' to 'right_id'?(Is there some option like 'foreign_key'?)