I have self reference habtm
assotiation.
class Label < AR::B
has_and_belongs_to_many :a_label, :class_name => "Label",
:join_table => "a_labels",
:foreign_key => "label_id",
:association_foreign_key => "a_label_id",
:uniq => true
end
But when i create query (with squeel
):
Label.select{:title}.where do
id.in(Label.select{:a_label_id}.joins(:a_labels).where{
labels.title.in(list)
})
Schema:
labels:
id | title | description | created_at
a_labels
label_id | a_label_id
I got error:
ActiveRecord::ConfigurationError:
Association named 'a_labels' was not found; perhaps you misspelled it?
Where I was mistaken? Thanks.