0

In my rails app I have teams and staff of which staff are members of a team. Both objects have ordinals which I want to sort by ascending.

How do I do this? I tried:

@teams = Team.all.order('"teams"."ordinal" asc, "staffs"."ordinal" asc')

But it didn't work... and gives me the error:

SQLite3::SQLException: no such column: staffs.ordinal: SELECT "teams".* FROM "teams" ORDER BY "teams"."ordinal" asc, "staffs"."ordinal" asc

1 Answer 1

2

Try this

Team.includes(:staffs).order('teams.ordinal', 'staffs.ordinal').all

I am not sure how your relationship is setup since you haven't provided that information. I am only giving you a hint of how it should be done

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.