← Back to Upcase

CRUD, Validations, and Partials

© 2012 - 2017 thoughtbot, inc. Upcase, the design of a robot, and thoughtbot are registered trademarks of thoughtbot, inc.

This is a companion discussion topic for the original entry at https://thoughtbot.com/upcase/videos/intermediate-rails-2

The instructor mention that there are other ways for the sorting the shouts but did not enumerate the options he was talking about. Was I thinking maybe the other option is sorting in the controller? Would love to know the other options as well.

You can sort in the controller, but from my understanding, it’s not best practice to do so. I believe it’s better to having sorting methods within your model, then use them in your controller whenever necessary.

Here’s a good reference on WHY it’s usually not such a good idea to use default scopes for the curious.

I noticed the commenters here mention default_scope (which I generally agree with, I would probably manually order the results in the view or controller), but I feel that that was a small part of the lesson which was fairly articulated why it was dangerous.

I thoroughly enjoyed this video, it’s really a breath of fresh air to watch someone building an app from scratch, without shortcuts, and talking their way through it. Still very relevant in 2020.