Glad You're Ready. Let's Get Started!

Let us know how we can contact you.

Thank you!

We'll respond shortly.

[Standup][SF] 06/06/12: Remember…


  • Nested route parameters are remembered

If you’re in a controller action and you get there via a nested route, any path helpers you call automagically get the ID of the resource you’re nested under. The route helpers reverse-merge in the parameters of the request.

This means if you have these routes:

resources :magazines do
resources :ads

and you’re in an action in the ads controller, nested under magazine 5, you can do this:


without passing in a magazine object. It will pull magazine_id 5 out of the request parameters.

  • (1..100).grep 38..44

results in

[38, 39, 40, 41, 42, 43, 44]

As per ruby enumerable docs.

This is because grep uses threequel, which on a range is defined as inclusion. Answer courtesy of Giles Bowkett

Post a Comment

Your Information (Name required. Email address will not be displayed with comment.)

* Copy This Password *

* Type Or Paste Password Here *