This question already has an answer here:
I have models Description
and Click
. Description
has many Clicks
.
How can I sort Descriptions
by column in Click
?
Try...
Description.joins(:click).order('click.column_name')
If this doesn't work, you may need to call .all before your joins condition, like so:
Description.all.joins(:click).order('click.column_name')
Association named 'click' was not found on Description; perhaps you misspelled it?
But relationships are done well cause when I create click it has description id and everything works good. - TeTiRoss