Re: [SDRuby] Problem with using XMLHttpRequest to PUT into a Rails 2 app in production

2014-10-24 Thread Graeme Worthy
To expand a little on what mike has already said. In addition to the 'regular' rails http methods. GET, POST, PUT, DELETE there is another request type: OPTIONS Before a cors-aware browser will do your POST/PUT request, it sends it's own request in secret the browser sends a request using the OPTI

Re: [SDRuby] Problem with using XMLHttpRequest to PUT into a Rails 2 app in production

2014-10-23 Thread Scott Olmsted
Mike, I think you're right and I would love to do what they did at that link (add HTTP headers at the controller level), but the code never gets that far, the OPTION is rejected by Rails first. Since I haven't been able to get the rack-cors gem working at all, even with Ian's observation that

Re: [SDRuby] Problem with using XMLHttpRequest to PUT into a Rails 2 app in production

2014-10-23 Thread Michael Costanza
Hi Scott, >From the first line of your stack trace you can see the request method is actually OPTIONS which is a preflight CORS request: *Processing ApplicationController#index (for xx.xxx.xx.xxx at 2014-10-22 14:31:28) [OPTIONS]* The application needs to send a response for the OPTIONS request

Re: [SDRuby] Problem with using XMLHttpRequest to PUT into a Rails 2 app in production

2014-10-22 Thread Ian Young
It's easy to forget how far Rails has come until you try to maintain a Rails 2 app :) Judging by this Railscast[1], it sounds like 2.3 does support Rack middleware, so you might still be in luck. It looks like maybe you just need different syntax. Instead of: config.middleware.use Rack::Cors ma

Re: [SDRuby] Problem with using XMLHttpRequest to PUT into a Rails 2 app in production

2014-10-22 Thread Scott Olmsted
Ian, Thanks! Unfortunately, there is no guidance to be had on using rack-cors with Rails 2. Besides adding the gem to Gemfile: *gem 'rack-cors', :require => 'rack/cors'* initialization should likely go in config/environment.rb, like: > > > > > > > > > > *Rails::Initializer.run do |config|

Re: [SDRuby] Problem with using XMLHttpRequest to PUT into a Rails 2 app in production

2014-10-22 Thread Ian Young
Scott, It looks like Rails is receiving an OPTIONS request and choking on it. This is generally an indication of CORS taking place (on PUT/POSTs with CORS, it first performs a "pre-flight" OPTIONS request to see if the actual request is allowed). I'm not sure what kind of stuff you have set up in

[SDRuby] Problem with using XMLHttpRequest to PUT into a Rails 2 app in production

2014-10-22 Thread Scott Olmsted
A client with a Rails 2 app that displays games written in Flash is having them converted to HTML5/Javascript. The team doing the conversions has no problem reading the player's data with a Javascript function like this, which I bound to a button click and ran with the Chrome debugging console