I have the following url structure in rails routes:
match '/financial-dictionary/:letter' => 'learning_center#dictionary', :as => :lc_dictionary
Do i need a leading slash in front of "financial-dictionary"? What will happen if i remove it?
Rails routing is a two-way piece of machinery – rather as if you could turn trees into paper, and then turn paper back into trees. Specifically, it both connects incoming HTTP requests to the code in your application's controllers, and helps you generate URLs without having to hard-code them as strings.
TIP: If you ever want to list all the routes of your application you can use rails routes on your terminal and if you want to list routes of a specific resource, you can use rails routes | grep hotel . This will list all the routes of Hotel.
Rails supports concerns in Routes. Concerns can be defined in Rails routes to be able to have reusable routes. Sometimes, we need similar routes for different resources.
This is the simple option. When you use namespace , it will prefix the URL path for the specified resources, and try to locate the controller under a module named in the same manner as the namespace.
Short answer: nope, you don't need.
You might want to read http://guides.rubyonrails.org/routing.html :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With