I want to access the table "Words" from the "linked_to" column, and not from "id" column.
The INNER JOIN query created by Rails always search for the id column in the Words table.
This is what I want to do :
- From the Class Point,
- Do an inner join to "linked_to" column (I already specify the :foreign_key)
- "Linked_to" is not unique in the "Words" table, because there is one line per translation
- Filter (Select) in the Words table, the value corresponding to my current language (let's assume dictionnary = 1)
My current Model
class Word < ActiveRecord::Base
has_and_belongs_to_many :points, :foreign_key => "linked_to"
belongs_to :dictionnary
attr_accessible :lang, :value, :dictionnary_id, :language_id, :linked_to
end
class Point < ActiveRecord::Base
has_and_belongs_to_many :words, :association_foreign_key => "linked_to"
belongs_to :priority
attr_accessible :edited_by
end