Philip Hallstrom
2008-Jul-21 21:36 UTC
Preferred way to disable parts of a RESTful resource?
Hi all - I''ve got my RESTful resource all setup. However, there is no editing or destroying allowed. What''s the preferred way to disable those? - remove the action? (don''t like this idea) - redirect within the action skipping the actual edit/destroy call? - returning an error? (is there a standard here?) Thanks! -philip --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
remove the action (method) from the controller. if you don''t want code to be executed, don''t provide the code to execute. On Jul 21, 5:36 pm, Philip Hallstrom <phi...-LSG90OXdqQE@public.gmane.org> wrote:> Hi all - > > I''ve got my RESTful resource all setup. However, there is no editing > or destroying allowed. What''s the preferred way to disable those? > > - remove the action? (don''t like this idea) > - redirect within the action skipping the actual edit/destroy call? > - returning an error? (is there a standard here?) > > Thanks! > > -philip--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
def edit render ''404.html'' end def destroy render ''404.html'' end On 22/07/2008, at 7:24 AM, jemminger wrote:> > remove the action (method) from the controller. if you don''t want > code to be executed, don''t provide the code to execute. > > On Jul 21, 5:36 pm, Philip Hallstrom <phi...-LSG90OXdqQE@public.gmane.org> wrote: >> Hi all - >> >> I''ve got my RESTful resource all setup. However, there is no editing >> or destroying allowed. What''s the preferred way to disable those? >> >> - remove the action? (don''t like this idea) >> - redirect within the action skipping the actual edit/destroy call? >> - returning an error? (is there a standard here?) >> >> Thanks! >> >> -philip > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Wojciech Piekutowski
2008-Jul-22 19:15 UTC
Re: Preferred way to disable parts of a RESTful resource?
Hi, According to the HTTP specs, when a particular request method isn''t supported for a resource identified by a URI, server should return 405 HTTP code. Wojtek --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Aloha Philip, We use: def delete respond_to do |format| format.html raise(:method_not_allowed) format.xml {render :xml=>exception, :status=>405} end end for any methods that aren''t allowed. As Wojtek said, you are supposed to return a 405 on items that aren''t allowed not a 404. Best of luck, DrMark On Jul 22, 9:15 am, Wojciech Piekutowski <w.piekutow...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, > > According to the HTTP specs, when a particular request method isn''t > supported for a resource identified by a URI, server should return 405 > HTTP code. > > Wojtek--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---