Relearning routes in Rails

705 views

Published on

Some differences between routes from Rails 2 to Rails 3.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
705
On SlideShare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
5
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Relearning routes in Rails

  1. 1. Relearning routes in Rails<br />Routes in Rails 3<br />Juliana M. de Lucena<br />@julianalucenaa<br />(Yes, it has two ‘a’)<br />
  2. 2. “I love URLs. I dream about them at night. I think about them before I think about anything else.”<br />Adrian Holovaty, co-creator of Django<br />From Webstock 2009<br />
  3. 3. What have changed?<br />(From version 2 to 3)<br />Everything<br />Almost<br />
  4. 4. Our Path<br />Good perceptions<br />Block declaration<br />Let’s see some routes<br />Root<br />Resource<br />Default<br />Using constraints<br />Redirect<br />Namespace on route<br />Translating<br />Let’s MAKE some routes<br />
  5. 5. Good Perceptions<br />Concise<br />Clean<br />Fast<br />In a Rubyish-way<br />
  6. 6. Block Declaration<br />Old one<br />New one<br />You do not need to use map anymore<br />
  7. 7. Let’s see some routing<br />Root route<br />Old one<br />New one<br />Concise<br />
  8. 8. Let’s see some routing<br />Resource route<br />Nested resources<br />“Resources should never be nested more than 1 level deep.” Rails Guides<br />Old one<br />New one<br />Clean<br />
  9. 9. Let’s see some routing<br />Resource route<br />Adding some routes<br />Old one<br />New one<br />or<br />Rubyish<br />
  10. 10. Let’s see some routing<br />Default route<br />Old one<br />New one<br />And you can name it like below<br />It generates show_tag_type_path<br />
  11. 11. Tired of showing Rails 2 examples<br />Sorry<br />Let’s move on without them<br />
  12. 12. Let’s see some routing<br />Using constraints<br />On HTTP method<br />On some fragment<br />
  13. 13. Let’s see some routing<br />Redirect route<br />Namespace on route<br />Admin::LibrariesController<br />
  14. 14. Let’s see some routing<br />Translating routes (it can be useful for us?)<br />
  15. 15. Enough! <O><br />Let’s MAKE some routing<br />You can see more surfing through the web<br />
  16. 16. Let’s MAKE some routing<br />Some advises<br /> In a DOJO way<br />We are interest just on routes, forget about view, models and controllers things<br />Do not be scared with specification, it will be very simple<br />Control your anxiety, it is on next page<br />
  17. 17. Let’s MAKE some routing<br /> Exists a library<br />That has many books, employees and students<br />A book<br />Can be created, edited, updated, deleted by any employee<br />Can be seen, borrowed and returned by everyone<br />Is identified by a five characters code<br />All employees<br />Can access some library private informationsthrough a special URL that begins with ‘admin’<br />Post method<br />
  18. 18. Let’s MAKE some routing<br /> The library changed the name:<br />When somebody access /my_old_library should redirect to /my_new_library<br />With ‘/library/branchs’ we can see all libraries physical addresses (static page)<br />Do not forget the root path<br />All routes should be translated to portuguese<br />
  19. 19. Thank you all<br />See u later<br />
  20. 20. References<br />Routing in Rails 3 - #203 Railscastsepisode<br />Ruby on Rails guidesand 2.3.8 version<br />http://www.engineyard.com/blog/2010/the-lowdown-on-routes-in-rails-3/<br />routes.rb itself<br />
  21. 21. Juliana M. de Lucena<br />@julianalucenaa<br />(Yes, it has two ‘a’)<br />

×