1

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?

1 답변


2

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')


  • @HassebAhmad I got error: 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
  • Change click to clicks has many relationship names are pluralized - CWitty

Linked


Related

Latest