Link to home
Start Free TrialLog in
Avatar of YPU
YPU

asked on

Upgrade Ruby from 1.8.7 to 1.9.2-p320

I recently upgraded my web app from Ruby 1.8.7 to 1.9.2-p320 and while there were a few hiccups, most everything was minor.

However, I am having one major issue that is baffling me. I've been spinning my wheels for over a day now and that is never a good thing.

In several instances within my app, I am using ajax requests to process updates. This was working flawlessly when I was running Ruby 1.8.7, but now I am getting the following error (taken from firebug console):

<h1>ActionController::MethodNotAllowed</h1>
<pre>Only get requests are allowed.</pre>

/Users/nathanarnold/.rvm/gems/ruby-1.9.2-p320/gems/actionpack-2.3.17/lib/action_controller/routing/recognition_optimisation.rb:64:in `recognize_path&#39;
/Users/nathanarnold/.rvm/gems/ruby-1.9.2-p320/gems/actionpack-2.3.17/lib/action_controller/routing/route_set.rb:442:in `recognize&#39;
/Users/nathanarnold/.rvm/gems/ruby-1.9.2-p320/gems/actionpack-2.3.17/lib/action_controller/routing/route_set.rb:437:in `call&#39;
/Users/nathanarnold/.rvm/gems/ruby-1.9.2-p320/gems/actionpack-2.3.17/lib/action_controller/dispatcher.rb:87:in `dispatch&#39;
/Users/nathanarnold/.rvm/gems/ruby-1.9.2-p320/gems/actionpack-2.3.17/lib/action_controller/dispatcher.rb:121:in `_call&#39;
/Users/nathanarnold/.rvm/gems/ruby-1.9.2-p320/gems/actionpack-2.3.17/lib/action_controller/dispatcher.rb:130:in `block in build_middleware_stack&#39;
/Users/nathanarnold/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-2.3.17/lib/active_record/query_cache.rb:29:in `call&#39;
/Users/nathanarnold/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-2.3.17/lib/active_record/query_cache.rb:29:in `block in call&#39;
/Users/nathanarnold/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-2.3.17/lib/active_record/connection_adapters/abstract/query_cache.rb:34:in `cache&#39;
/Users/nathanarnold/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-2.3.17/lib/active_record/query_cache.rb:9:in `cache&#39;
/Users/nathanarnold/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-2.3.17/lib/active_record/query_cache.rb:28:in `call&#39;
/Users/nathanarnold/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-2.3.17/lib/active_record/connection_adapters/abstract/connection_pool.rb:361:in `call&#39;
/Users/nathanarnold/.rvm/gems/ruby-1.9.2-p320/gems/actionpack-2.3.17/lib/action_controller/string_coercion.rb:25:in `call&#39;
/Users/nathanarnold/.rvm/gems/ruby-1.9.2-p320/gems/rack-1.1.6/lib/rack/head.rb:9:in `call&#39;
/Users/nathanarnold/.rvm/gems/ruby-1.9.2-p320/gems/rack-1.1.6/lib/rack/methodoverride.rb:24:in `call&#39;
/Users/nathanarnold/.rvm/gems/ruby-1.9.2-p320/gems/actionpack-2.3.17/lib/action_controller/params_parser.rb:15:in `call&#39;
/Users/nathanarnold/.rvm/gems/ruby-1.9.2-p320/gems/actionpack-2.3.17/lib/action_controller/session/cookie_store.rb:99:in `call&#39;
/Users/nathanarnold/.rvm/gems/ruby-1.9.2-p320/gems/hoptoad_notifier-2.4.11/lib/hoptoad_notifier/rack.rb:27:in `call&#39;
/Users/nathanarnold/.rvm/gems/ruby-1.9.2-p320/gems/actionpack-2.3.17/lib/action_controller/failsafe.rb:26:in `call&#39;
/Users/nathanarnold/.rvm/gems/ruby-1.9.2-p320/gems/hoptoad_notifier-2.4.11/lib/hoptoad_notifier/user_informer.rb:12:in `call&#39;
/Users/nathanarnold/.rvm/gems/ruby-1.9.2-p320/gems/rack-1.1.6/lib/rack/lock.rb:11:in `block in call&#39;
&lt;internal:prelude&gt;:10:in `synchronize&#39;
/Users/nathanarnold/.rvm/gems/ruby-1.9.2-p320/gems/rack-1.1.6/lib/rack/lock.rb:11:in `call&#39;
/Users/nathanarnold/.rvm/gems/ruby-1.9.2-p320/gems/actionpack-2.3.17/lib/action_controller/dispatcher.rb:114:in `block in call&#39;
/Users/nathanarnold/.rvm/gems/ruby-1.9.2-p320/gems/actionpack-2.3.17/lib/action_controller/reloader.rb:34:in `run&#39;
/Users/nathanarnold/.rvm/gems/ruby-1.9.2-p320/gems/actionpack-2.3.17/lib/action_controller/dispatcher.rb:108:in `call&#39;
/Users/nathanarnold/.rvm/gems/ruby-1.9.2-p320/gems/rails-2.3.17/lib/rails/rack/static.rb:31:in `call&#39;
/Users/nathanarnold/.rvm/gems/ruby-1.9.2-p320/gems/rack-1.1.6/lib/rack/urlmap.rb:47:in `block in call&#39;
/Users/nathanarnold/.rvm/gems/ruby-1.9.2-p320/gems/rack-1.1.6/lib/rack/urlmap.rb:41:in `each&#39;
/Users/nathanarnold/.rvm/gems/ruby-1.9.2-p320/gems/rack-1.1.6/lib/rack/urlmap.rb:41:in `call&#39;
/Users/nathanarnold/.rvm/gems/ruby-1.9.2-p320/gems/rails-2.3.17/lib/rails/rack/debugger.rb:19:in `call&#39;
/Users/nathanarnold/.rvm/gems/ruby-1.9.2-p320/gems/rails-2.3.17/lib/rails/rack/log_tailer.rb:17:in `call&#39;
/Users/nathanarnold/.rvm/gems/ruby-1.9.2-p320/gems/rack-1.1.6/lib/rack/content_length.rb:13:in `call&#39;
/Users/nathanarnold/.rvm/gems/ruby-1.9.2-p320/gems/rack-1.1.6/lib/rack/chunked.rb:15:in `call&#39;
/Users/nathanarnold/.rvm/gems/ruby-1.9.2-p320/gems/rack-1.1.6/lib/rack/handler/mongrel.rb:67:in `process&#39;
/Users/nathanarnold/.rvm/gems/ruby-1.9.2-p320/gems/mongrel-1.2.0.pre2/lib/mongrel.rb:165:in `block in process_client&#39;
/Users/nathanarnold/.rvm/gems/ruby-1.9.2-p320/gems/mongrel-1.2.0.pre2/lib/mongrel.rb:164:in `each&#39;
/Users/nathanarnold/.rvm/gems/ruby-1.9.2-p320/gems/mongrel-1.2.0.pre2/lib/mongrel.rb:164:in `process_client&#39;
/Users/nathanarnold/.rvm/gems/ruby-1.9.2-p320/gems/mongrel-1.2.0.pre2/lib/mongrel.rb:291:in `block (2 levels) in run&#39;

Open in new window


I am using the following plugins to make this code work:

jrails
less-js-routes

I have applied all of the Ruby 1.9 patches but I keep getting the 405 Method Not Allowed Error when attempting to run things like:

<a href="#" id="edit_coupon" onclick="jQuery.ajax({data:'', dataType:'script', type:'post', url:'/coupons/60/edit'}); return false;">Edit</a>

Open in new window




Does anyone have any ideas? I am fresh out of them.

Thanks.
Avatar of Andrew Doades
Andrew Doades
Flag of United Kingdom of Great Britain and Northern Ireland image

Can you post your routes.rb file please?
Avatar of YPU
YPU

ASKER

ActionController::Routing::Routes.draw do |map|
  map.resources :businesses,
    :collection => {
      :preview          => :get,
    },
    :member => {
     :take_ownership    => :get,
     :create_ownership  => :post,
     :edit_popup        => :get,
     :rate              => :put,
     :contact           => :any,
    } do |business|

    business.resource  :about_us, :controller => 'business_about_us'
    business.resource  :address, :controller => 'business_addresses'
    business.resource  :billing_info, :controller => 'business_billing_info'
    business.resources :content_blocks, :controller => 'business_content_blocks'
    business.resource  :hours_of_operation, :controller => 'business_hours_of_operation'
    business.resource  :status_update
    business.resource  :video, :controller => 'business_video'

    business.resources :photos, :controller => 'business_photos',
      :member => {
        :cancel => :get,
        :crop => :get,
        :rotate => :get,
        :save => :get
      }

    business.resources :reviews, :controller => 'business_reviews'
  end
  
  map.namespace :service_credentials do |creds|
    creds.resources :twitter,
      :only => [],
      :collection => {
        :login => :get,
        :logout => :get,
        :callback => :get,
        :toggle_default => :get
      }, :controller => 'twitter_credentials'
    creds.resources :facebook,
      :only => [],
      :collection => {
        :logout => :get,
        :callback => :get,
        :toggle_default => :get
      }, :controller => 'facebook_credentials'
  end

  map.resources :cities

  map.resources :messages,
    :member => {
      :delete           => :put,
      :mark_as_unread   => :put,
      :reply            => :any
    }

  map.resources :reviews,
    :member => {
      :mark_as_unread   => :put,
      :reply            => :any,
      :suspend          => :any
    }

  map.resources :coupons,
    :member => {
      :activate         => :get,
      :deactivate       => :get
    }

  map.traffic 'traffic', :controller => 'traffic'
  map.lifetime 'lifetime.:format', :controller => 'traffic', :action => 'lifetime'

  map.resource  :session

  map.resources :users,
    :collection => {
      :terms => :get
    },
    :member => {
      :cancel => :get
    }

  map.namespace :backend do |backend|
    backend.resources :business_comparisons, :only => [:index, :show]
    backend.resources :businesses, :only => [:index], :member => { :pull => [:get, :post] }
    backend.resources :users, :only => [:index]
  end

  map.namespace :crossroad do |crossroad|
    crossroad.resources :business, :member => {:cancel => :delete}
  end

  map.rating '/businesses/:id/rate/:rating', :controller => 'businesses', :action => 'rate', :method => :put

  map.categories_for_city 'categories/:id/for/:city', :controller => 'categories', :action => 'show'

  map.about    'yellow-pages-united',   :controller => 'content', :action => 'about'
  map.abuse    'abuse',   :controller => 'content', :action => 'abuse'
  map.privacy  'privacy', :controller => 'content', :action => 'privacy'
  map.sitemap  'sitemap', :controller => 'content', :action => 'sitemap'
  map.contact_ypu  'contact_ypu', :controller => 'content', :action => 'contact_ypu'
  
  map.help  'help', :controller => 'content', :action => 'help'
  map.featured  'featured', :controller => 'content', :action => 'featured'
  map.featured  'recent', :controller => 'content', :action => 'recent'
  map.learn_how    'learn_how',   :controller => 'content', :action => 'learn_how'
  map.phone_search 'phone_search', :controller => 'content', :action => 'phone_search'

  map.dashboard 'dashboard', :controller => 'dashboard'

  map.formatted_search 'search.:format', :controller => 'search'
  map.new_search       'searching',      :controller => 'search', :action => 'new'
  map.search           'search',         :controller => 'search'

  map.forgot_password 'forgot_password', :controller => 'sessions', :action => 'forgot_password'
  map.login           'login',           :controller => 'sessions', :action => 'new'
  map.logout          'logout',          :controller => 'sessions', :action => 'destroy'
  map.reset_password  'reset_password',  :controller => 'sessions', :action => 'reset_password'

  map.root :controller => 'content'
end

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of YPU
YPU

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of YPU

ASKER

The above now works with the following:

business.resources :photos, :controller => 'business_photos',
      :member => {
        :cancel => :get,
        :crop => :get,
        :rotate => :get,
        :save => :get,
        :show => :post
      }

Open in new window

Avatar of YPU

ASKER

SO, now I guess my question is:

What changed from Ruby 1.8 to 1.9 that makes me have to set those routes?