AJ ONeal
2010-Jan-11  23:52 UTC
How to add a route to the method ''options'' for each controller?
Currently I''m mapping all of my controllers to use the same set of http
options in a controller called option
  map.connect ''*path'',
            :controller => ''option'',
            :action => ''options'',
            :conditions => {:method => :options}
But I would like to know how to do something along these lines
  map.connect '':controller*'',
            :action => ''options'',
            :conditions => {:method => :options}
Which currently yields
  Allow: GET, POST, PUT, DELETE
  Status: 501 Not Implemented
The goal is that whenever a client application pre-flights a cross-origin
request (CORS) the controller will issue the same options regardless of the
action, but contingent upon the controller.
This is the options method which I would like to be able to control on a
per-controller basis:
  def options
      render :nothing => true, :status => 204
      response.headers[''Access-Control-Allow-Origin''] =
''*''
      response.headers[''Access-Control-Allow-Methods''] =
''POST, GET, PUT,
DELETE, OPTIONS''
      response.headers[''Access-Control-Allow-Credentials''] =
''true''
      response.headers[''Access-Control-Max-Age''] =
''86400''
      response.headers[''Access-Control-Allow-Headers''] =
''X-Requested-With,
X-HTTP-Method-Override, Content-Type, Accept''
  end
AJ ONeal
-- 
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.
CoolAJ86
2010-Jan-15  19:47 UTC
Re: How to add a route to the method ''options'' for each controller?
I found the answer to my question and here''s a link to the other thread: http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/29c8e6f4175b1676 -- 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.