Norbert Melzer
2011-Oct-15 18:42 UTC
[RAILS] Removing (.:format) from a resource in routes
Hi!
I have a routes.rb like this:
Xxx::Application.routes.draw do
resources :sessions, :only => [ :new, :create, :destroy ]
resources :users
root :to => ''welcome#index''
end
this produces the following in rake routes:
nmelzer@ubuntu-Delly:~/Dokumente/sources/ruby/1.9.2/rails3.1/xxx$ rake
routes
users_new GET /users/new(.:format) {:controller=>"users",
:action=>"new"}
sessions POST /sessions(.:format) {:action=>"create",
:controller=>"sessions"}
new_session GET /sessions/new(.:format) {:action=>"new",
:controller=>"sessions"}
session DELETE /sessions/:id(.:format) {:action=>"destroy",
:controller=>"sessions"}
users GET /users(.:format) {:action=>"index",
:controller=>"users"}
POST /users(.:format) {:action=>"create",
:controller=>"users"}
new_user GET /users/new(.:format) {:action=>"new",
:controller=>"users"}
edit_user GET /users/:id/edit(.:format) {:action=>"edit",
:controller=>"users"}
user GET /users/:id(.:format) {:action=>"show",
:controller=>"users"}
PUT /users/:id(.:format) {:action=>"update",
:controller=>"users"}
DELETE /users/:id(.:format) {:action=>"destroy",
:controller=>"users"}
root /
{:controller=>"welcome",
:action=>"index"}
Since I am only serving HTML and dont plan to serv other formats I
want to get rid of all the (.:format) in the routes, is that possible?
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
Jim Morris
2011-Oct-15 23:14 UTC
Re: [RAILS] Removing (.:format) from a resource in routes
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 -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/4UliA2W07HwJ. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Norbert Melzer
2011-Oct-16 05:41 UTC
Re: Re: [RAILS] Removing (.:format) from a resource in routes
2011/10/16 Jim Morris <wolfmanjm-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:> 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 GlobbingThank you, I did a quick look on that page yesterday before asking, but I could not find it. I really could have give CTRL+F a try :D Bye Norbert -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.