Skip to content

Instantly share code, notes, and snippets.

@nmcolome
Created May 17, 2017 17:33
Show Gist options
  • Save nmcolome/a77db4ffc8602c2de5438217a502bb0a to your computer and use it in GitHub Desktop.
Save nmcolome/a77db4ffc8602c2de5438217a502bb0a to your computer and use it in GitHub Desktop.
CFU - Advanced Routing Rails

Checks for Understanding

  • Why do we namespace things?

To assign context and create a different scope of responsability (maybe limit access, have different functionality, etc).

  • What is the difference between namespacing and scoping?

When we assign a scope we only change the URI pattern, with namespacing we change the prefix, URI pattern and controller#action so we can call it on their own and thus creating a new 'umbrella of responsability'

  • When would we use one over the other?

We would use Scoping for better readability for the user; we would use Namespacing to create new paths, and particular actions and views depending on the scope the user is in.

  • When should you use nested resources?

When we want this relationship to depend on a specific resource (:id) (nested resources include the :id of the parent, namespacing does not).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment