Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do I need a slash in front of rails route

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?

like image 848
Tamik Soziev Avatar asked Mar 30 '12 14:03

Tamik Soziev


People also ask

How do Rails routes work?

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.

How do I see Rails routes?

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.

What is concern in Rails routes?

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.

What is namespace in Rails routes?

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.


1 Answers

Short answer: nope, you don't need.

You might want to read http://guides.rubyonrails.org/routing.html :)

like image 77
jipiboily Avatar answered Oct 13 '22 20:10

jipiboily