heroku:ActionController :: RoutingError(没有路由匹配[GET]" / newrelic")

时间:2014-05-27 14:40:08

标签: ruby heroku ruby-on-rails-4 newrelic

ERROR

ActionController::RoutingError (No route matches [GET] "/newrelic")

# and I am getting error page for both staging and production heroku servers

文档

https://devcenter.heroku.com/articles/newrelic

GEM

https://github.com/newrelic/rpm

# ruby 2.1.0p0
# rails 4.0.1

环境变量NEW_RELIC_LICENSE_KEYNEW_RELIC_APP_NAME都设置为heroku配置变量

Gemfile

gem "newrelic_rpm", "~> 3.5.7.59"

config/newrelic.yml

common: &default_settings
  license_key: <%= ENV['NEW_RELIC_LICENSE_KEY'] %>
  app_name: <%= ENV["NEW_RELIC_APP_NAME"] %>
  monitor_mode: true
  developer_mode: false
  log_level: info

  browser_monitoring:
    auto_instrument: true

  audit_log:
    enabled: false
    capture_params: false

  transaction_tracer:
    enabled: true
    transaction_threshold: apdex_f
    record_sql: obfuscated
    stack_trace_threshold: 0.500

  error_collector:
    enabled: true
    capture_source: true
    ignore_errors: "ActionController::RoutingError,Sinatra::NotFound"

development:
  <<: *default_settings
  monitor_mode: true
  developer_mode: true

test:
  <<: *default_settings
  monitor_mode: false

production:
  <<: *default_settings
  monitor_mode: true

staging:
  <<: *default_settings
  monitor_mode: true
  app_name: <%= ENV["NEW_RELIC_APP_NAME"] %> (Staging)

[注意:我有两个应用程序托管到heroku:]

  • (分段).herokuapp.com
  • (生产).herokuapp.com

我想为两个环境/服务器配置新文件。

另请注意,此配置在开发(localhost)环境中工作正常。

EDITED

config/routes.rb

Demo::Application.routes.draw do
  root :to => "home#index"

  devise_for :users,:controllers => {:sessions => "sessions",:omniauth_callbacks => "omniauth_callbacks" }
  post '/tinymce_assets' => 'tinymce_assets#create'
  resources :home

  namespace :admin do
    resources :dashboards

    resources :users do
      member do
        get :reset
        put :reset_pw
        put :delete_record
        put :restore_user
      end
    end
  end

  resources :drives do
    member do
      put :destroy_drive
      post :add_consolidation
      put :delete_consolidation
      post :add_driveorganizer
      put :delete_drive_organizer
      put :restore_drirve
    end
    collection do
       get :recalculate_consolidation
    end
    resources :drive_details do
      resources :images
    end
  end

  resources :products do
    member do
      post :add_category
      put :destroy_pc
      put :delete_product
      put :restore_products
    end
  end

  resources :stores do
    member do
      put :delete_store
    end
  end

  resources :store_products do
    member do
      put :delete_storeproduct
      post :add_package_items
      put :delete_package_item
      put :restore_store_product
      get :get_product_price
    end
    collection do
      get :autocomplete_others
    end
  end

  resources :orders do
    member do
      put :delete_order
      put :restore_order
      get :charge_stripe
    end

    resources :order_items do
      collection do
        post :display_price
      end
      member do
        put :delete_record
      end
    end
  end

  resources :categories do
    member do
      put :delete_category
      put :restore_category
    end

    collection do
      get :move
    end
  end

  namespace :user do
    resources :campaigns do
      member do
        get :single_campaign
      end
      resources :stores 
      resources :carts do 
        collection do
          post :carts_update
          get :checkout_final
          get :payment
          post :payment
          get :update_payment
          get :update_payment_and_redirect
          get :confirmation
          post :confirmation
          get :finish
          post :confirmation_update
          put :empty_cart
          post :shelter_survey
        end
        member do
          put :destroy_oi
          put :checkout
        end
      end
    end
  end

  # The priority is based upon order of creation: first created -> highest priority.
  # See how all your routes lay out with "rake routes".

  # You can have the root of your site routed with "root"
  # root 'welcome#index'

  # Example of regular route:
  #   get 'products/:id' => 'catalog#view'

  # Example of named route that can be invoked with purchase_url(id: product.id)
  #   get 'products/:id/purchase' => 'catalog#purchase', as: :purchase

  # Example resource route (maps HTTP verbs to controller actions automatically):
  #   resources :products

  # Example resource route with options:
  #   resources :products do
  #     member do
  #       get 'short'
  #       post 'toggle'
  #     end
  #
  #     collection do
  #       get 'sold'
  #     end
  #   end

  # Example resource route with sub-resources:
  #   resources :products do
  #     resources :comments, :sales
  #     resource :seller
  #   end

  # Example resource route with more complex sub-resources:
  #   resources :products do
  #     resources :comments
  #     resources :sales do
  #       get 'recent', on: :collection
  #     end
  #   end

  # Example resource route with concerns:
  #   concern :toggleable do
  #     post 'toggle'
  #   end
  #   resources :posts, concerns: :toggleable
  #   resources :photos, concerns: :toggleable

  # Example resource route within a namespace:
  #   namespace :admin do
  #     # Directs /admin/products/* to Admin::ProductsController
  #     # (app/controllers/admin/products_controller.rb)
  #     resources :products
  #   end
end

由于

1 个答案:

答案 0 :(得分:3)

根据您获得的错误,您似乎正在尝试访问临时和生产环境中New Relic Ruby代理developer mode的路由。开发人员模式会在您的应用中安装一个中间件,以响应/newrelic前面的任何网址。因为您已在开发(localhost)环境中启用了开发人员模式(developer_mode下的true中的newrelic.yml密钥设置为development,所以访问此路由会在那里成功,但在暂存和生产方面失败,因为您没有在这些环境中启用开发者模式。

您的当前配置通常是可取的,因为开发人员模式会引入大量generally unacceptable in production的开销。而不是尝试在分段或生产中访问路径,而只在开发期间使用它。

您可能还需要考虑升级您正在使用的代理版本,因为版本3.5.7不完全支持Ruby 2.0或Rails 4.有关版本的更多信息可以在https://docs.newrelic.com/docs/releases/ruby找到。