2017-09-14 11 views
1

나는 루비 2.4.0, 레일 5.0.2, 애플 3.2 app을 가지고있다. 모든 인벤토리 제품을 볼 수있는 사용자 지정 관리 보고서를 만들려고했습니다. 지금은 추악하지만 앱이 충돌하는 제작과는 달리 개발에 완벽하게 작동합니다. 다음생산 과정에서 같은 이름의 두 경로. (Heroku)

option, or you may be overriding a route already defined by a resource with the same naming.으로 마지막으로 성공한 커밋 후, 모든 것이 예상 관련성, 추가 : 는 You may have defined two routes with the same name using the 말한다 heroku run rails c를 실행하는 경우

routes.rb

Rails.application.routes.draw do 
    mount Spree::Core::Engine, at: '/' 
    MyApp::Application.routes.draw do 
     Spree::Core::Engine.routes.append do 
     get '/admin/reports/stock_per_location' => 'admin/reports#stock_per_location', as: 'stock_per_location_admin_reports' 
     end 
    end 
end 

production.rb

Rails.application.configure do 
    config.cache_classes = true 

    config.eager_load = true 

    config.consider_all_requests_local  = false 
    config.action_controller.perform_caching = true 

    config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? 

    config.assets.js_compressor = :uglifier 
    config.assets.compile = true 

    config.log_level = :debug 

    config.log_tags = [ :request_id ] 

    config.action_mailer.perform_caching = false 

    config.i18n.fallbacks = true 

    config.active_support.deprecation = :notify 
    config.log_formatter = ::Logger::Formatter.new 


    if ENV["RAILS_LOG_TO_STDOUT"].present? 
    logger   = ActiveSupport::Logger.new(STDOUT) 
    logger.formatter = config.log_formatter 
    config.logger = ActiveSupport::TaggedLogging.new(logger) 
    end 

    config.active_record.dump_schema_after_migration = false 


    config.paperclip_defaults = { 
    storage: :s3, 
    s3_credentials: { 
     bucket: ENV.fetch('S3_BUCKET_NAME'), 
     access_key_id: ENV.fetch('AWS_ACCESS_KEY_ID'), 
     secret_access_key: ENV.fetch('AWS_SECRET_ACCESS_KEY'), 
     s3_region: ENV.fetch('AWS_REGION'), 
     url: ENV.fetch("BUCKET_URL"), 
    } 
    } 

end 

reports_controller_decorator.rb

require_dependency 'spree/admin/reports_controller' 

Spree::Admin::ReportsController.class_eval do 
    add_available_report! :stock_per_location 

    def stock_per_location 
    @stock_locations = Spree::StockLocation.all 
    end 
end 

답변

1

마지막으로 경로를 직접 만드는 것은 Spree의 최신 버전에서 지원되지 않으며 내 routes.rb가 변경되어 정상적으로 작동합니다.

MyApp::Application.routes.draw do 
     Spree::Core::Engine.routes.append do 
     #causing troubles on production: get '/admin/reports/stock_per_location' => 'admin/reports#stock_per_location', as: 'stock_per_location_admin_reports', only: [:index] 
     namespace :admin do 
     resources :reports, only: [:index] do 
      collection do 
      get :stock_per_location 
      #post :total_sales_of_each_product 
      end 
     end 
     end 
    end 
end