Could you tell me how to disable the .:format options in rails routes? I only need html...
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.
In Rails, a RESTful route provides a mapping between HTTP verbs, controller actions, and (implicitly) CRUD operations in a database. A single entry in the routing file, such as. map.resources :photos. creates seven different routes in your application: HTTP verb.
The routing module provides URL rewriting in native Ruby. It's a way to redirect incoming requests to controllers and actions. It replaces the mod_rewrite rules. Best of all, Rails' Routing works with any web server.
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.
In 3.1.1 at least you can add , :format => false
to the end of the route.
Found here: http://guides.rubyonrails.org/routing.html#request-based-constraints under section 3.11 Route Globbing
eg..
match '*pages' => 'pages#show', :format => false
Which would allow params[:pages] to include a period.
http://guides.rubyonrails.org/routing.html#request-based-constraints
This will constrain your routes to accept only html format:
constraints :format => "html" do
resources :posts do
resources :comments
end
end
However, it won't remove (.:format)
part from your rake routes
output.
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