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.

1 Like

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.

Cheers!

I am having issues following this tutorial I have come across several errors , current_user is empty and root cannot occur twice

Invalid route name, already in use: ‘root’

The fix for this issue is to rename our first root route with :as option.

  constraints Clearance::Constraints::SignedIn.new do
    root to: "dashboards#show", as: :authenticated_root
  end