I would like to set the routings as follows
/url/http://google.com
to urls
controller and index
action.What I have now in routes.rb
is:
match "urls/:url" => "urls#index"
The routing doesn't seem to work because the slashed in :url
.
In a nested route, the belongs_to (child) association is always nested under the has_many (parent) association. The first step is to add the nested routes like so: In the above Rails router example, the 'index' and 'show' routes are the only nested routes listed (additional or other resources can be added).
Rails RESTful Design which creates seven routes all mapping to the user controller. Rails also allows you to define multiple resources in one line.
Rails routes are matched in the order they are specified, so if you have a resources :photos above a get 'photos/poll' the show action's route for the resources line will be matched before the get line. To fix this, move the get line above the resources line so that it is matched first.
Or you can use Route Globbing:
match "urls/*url" => "urls#index"
You can access the values in your controller via params[:url]
Reference: http://guides.rubyonrails.org/routing.html Search for "Route Globbing"
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