3

レール 3.2.13

私は基本的に、このスクリーンキャストを使用して展開を追跡しようとしています: http://railscasts.com/episodes/335-deploying-to-a-vps

私は開発中のアプリを持っていますが、カピストラーノを使用して本番環境にプッシュすると、コントローラーのアクションのほとんどすべてが 404 ページになります。

「rake routes」を実行すると、このコントローラーのアクションが出力にないことに気付きました。

ルート.rb

Wagmantechnology::Application.routes.draw do

  root :to => 'static_pages#home'

  resources :users
  resources :sessions, only: [:new, :create, :destroy]
  resources :tasks
  resources :assets

  match '/signup',  to: 'users#new'
  match '/signin',  to: 'sessions#new'
  match '/signout', to: 'sessions#destroy', via: :delete

  match 'tasks/mjhartman' => "tasks#mjhartman", :as => "tasks_mjhartman"
  match 'tasks/ejmcfadden' => "tasks#ejmcfadden", :as => "tasks_ejmcfadden"
  match 'tasks/ctkahler' => "tasks#ctkahler", :as => "tasks_ctkahler"
  match 'tasks/gafc' => "tasks#gafc", :as => "tasks_gafc"
  match 'tasks/wci' => "tasks#wci", :as => "tasks_wci"
  match 'tasks/fsc' => "tasks#fsc", :as => "tasks_fsc"
  match 'tasks/wagco' => "tasks#wagco", :as => "tasks_wagco"
  match 'tasks/it' => "tasks#it", :as => "tasks_it"
  match 'tasks/atf' => "tasks#atf", :as => "tasks_atf"
  match 'tasks/hr' => "tasks#hr", :as => "tasks_hr"
  match 'tasks/legal' => "tasks#legal", :as => "tasks_legal"
  match 'tasks/marketing' => "tasks#marketing", :as => "tasks_marketing"
  match 'tasks/user_request' => "tasks#user_request", :as => "tasks_user_request"
  match 'tasks/jde' => "tasks#jde", :as => "tasks_jde"
  match 'tasks/communications' => "tasks#communications", :as => "tasks_communications"
  match 'tasks/hardware' => "tasks#hardware", :as => "tasks_hardware"
  match 'tasks/software' => "tasks#software", :as => "tasks_software"
  match 'tasks/documentation' => "tasks#documentation", :as => "tasks_documentation"
  match 'tasks/security' => "tasks#security", :as => "tasks_security"
  match 'tasks/billing' => "tasks#billing", :as => "tasks_billing"
  match 'tasks/training' => "tasks#training", :as => "tasks_training"
  match 'tasks/york_gafc' => "tasks#york_gafc", :as => "tasks_york_gafc"
  match 'tasks/york_wci' => "tasks#york_wci", :as => "tasks_york_wci"
  match 'tasks/berryville' => "tasks#berryville", :as => "tasks_berryville"
  match 'tasks/route52' => "tasks#route52", :as => "tasks_route52"
  match 'tasks/gafc_field' => "tasks#gafc_field", :as => "tasks_gafc_field"
  match 'tasks/wci_field' => "tasks#wci_field", :as => "tasks_wci_field"

  match 'assets/laptop' => "assets#laptop", :as => "assets_laptop"
  match 'assets/desktop' => "assets#desktop", :as => "assets_desktop"
  match 'assets/server' => "assets#server", :as => "assets_server"
  match 'assets/network' => "assets#network", :as => "assets_network"
  match 'assets/tablet' => "assets#tablet", :as => "assets_tablet"
  match 'assets/cell' => "assets#cell", :as => "assets_cell"
  match 'assets/data' => "assets#data", :as => "assets_data"
  match 'assets/office' => "assets#office", :as => "assets_office"
  match 'assets/printer' => "assets#printer", :as => "assets_printer"
  match 'assets/gafc' => "assets#gafc", :as => "assets_gafc"
  match 'assets/wci' => "assets#wci", :as => "assets_wci"
  match 'assets/fsc' => "assets#fsc", :as => "assets_fsc"
  match 'assets/wagco' => "assets#wagco", :as => "assets_wagco"
  match 'assets/it' => "assets#it", :as => "assets_it"
  match 'assets/atf' => "assets#atf", :as => "assets_atf"
  match 'assets/hr' => "assets#hr", :as => "assets_hr"
  match 'assets/legal' => "assets#legal", :as => "assets_legal"
  match 'assets/marketing' => "assets#marketing", :as => "assets_marketing"
  match 'assets/user_request' => "assets#user_request", :as => "assets_user_request"
  match 'assets/jde' => "assets#jde", :as => "assets_jde"
  match 'assets/communications' => "assets#communications", :as => "assets_communications"
  match 'assets/hardware' => "assets#hardware", :as => "assets_hardware"
  match 'assets/software' => "assets#software", :as => "assets_software"
  match 'assets/documentation' => "assets#documentation", :as => "assets_documentation"
  match 'assets/security' => "assets#security", :as => "assets_security"
  match 'assets/billing' => "assets#billing", :as => "assets_billing"
  match 'assets/training' => "assets#training", :as => "assets_training"
  match 'assets/york_gafc' => "assets#york_gafc", :as => "assets_york_gafc"
  match 'assets/york_wci' => "assets#york_wci", :as => "assets_york_wci"
  match 'assets/berryville' => "assets#berryville", :as => "assets_berryville"
  match 'assets/route52' => "assets#route52", :as => "assets_route52"
  match 'assets/gafc_field' => "assets#gafc_field", :as => "assets_gafc_field"
  match 'assets/wci_field' => "assets#wci_field", :as => "assets_wci_field"
  match 'assets/inventory' => "assets#inventory", :as => "assets_inventory"

end

「rake routes」からの出力:

                root        /                               static_pages#home
               users GET    /users(.:format)                users#index
                     POST   /users(.:format)                users#create
            new_user GET    /users/new(.:format)            users#new
           edit_user GET    /users/:id/edit(.:format)       users#edit
                user GET    /users/:id(.:format)            users#show
                     PUT    /users/:id(.:format)            users#update
                     DELETE /users/:id(.:format)            users#destroy
            sessions POST   /sessions(.:format)             sessions#create
         new_session GET    /sessions/new(.:format)         sessions#new
             session DELETE /sessions/:id(.:format)         sessions#destroy
               tasks GET    /tasks(.:format)                tasks#index
                     POST   /tasks(.:format)                tasks#create
            new_task GET    /tasks/new(.:format)            tasks#new
           edit_task GET    /tasks/:id/edit(.:format)       tasks#edit
                task GET    /tasks/:id(.:format)            tasks#show
                     PUT    /tasks/:id(.:format)            tasks#update
                     DELETE /tasks/:id(.:format)            tasks#destroy
              signup        /signup(.:format)               users#new
              signin        /signin(.:format)               sessions#new
             signout DELETE /signout(.:format)              sessions#destroy
     tasks_mjhartman        /tasks/mjhartman(.:format)      tasks#mjhartman
    tasks_ejmcfadden        /tasks/ejmcfadden(.:format)     tasks#ejmcfadden
      tasks_ctkahler        /tasks/ctkahler(.:format)       tasks#ctkahler
          tasks_gafc        /tasks/gafc(.:format)           tasks#gafc
           tasks_wci        /tasks/wci(.:format)            tasks#wci
           tasks_fsc        /tasks/fsc(.:format)            tasks#fsc
         tasks_wagco        /tasks/wagco(.:format)          tasks#wagco
            tasks_it        /tasks/it(.:format)             tasks#it
           tasks_atf        /tasks/atf(.:format)            tasks#atf
            tasks_hr        /tasks/hr(.:format)             tasks#hr
         tasks_legal        /tasks/legal(.:format)          tasks#legal
     tasks_marketing        /tasks/marketing(.:format)      tasks#marketing
  tasks_user_request        /tasks/user_request(.:format)   tasks#user_request
           tasks_jde        /tasks/jde(.:format)            tasks#jde
tasks_communications        /tasks/communications(.:format) tasks#communications
      tasks_hardware        /tasks/hardware(.:format)       tasks#hardware
      tasks_software        /tasks/software(.:format)       tasks#software
 tasks_documentation        /tasks/documentation(.:format)  tasks#documentation
      tasks_security        /tasks/security(.:format)       tasks#security
       tasks_billing        /tasks/billing(.:format)        tasks#billing
      tasks_training        /tasks/training(.:format)       tasks#training
     tasks_york_gafc        /tasks/york_gafc(.:format)      tasks#york_gafc
      tasks_york_wci        /tasks/york_wci(.:format)       tasks#york_wci
    tasks_berryville        /tasks/berryville(.:format)     tasks#berryville
       tasks_route52        /tasks/route52(.:format)        tasks#route52
    tasks_gafc_field        /tasks/gafc_field(.:format)     tasks#gafc_field
     tasks_wci_field        /tasks/wci_field(.:format)      tasks#wci_field

アセット ルートがまったく表示されていないことがわかります。なんで?奇妙なことに、 index アクション /assets は本番環境で機能しますが、それ以外は機能しません。すべてのリンクは開発中です。ここで何が間違っていますか?

4

1 に答える 1

2

理由は、アセット パイプラインとの名前の競合です。

ルーティングの「アセット」という言葉は機密性が高すぎます。Rails の静的アセットと同じです。localhost:3000/assets/rails.png開発環境では動作しますが、本番環境では動作しないことを確認できます。すべての「アセット」ルートは本番モードで変更されています。

私の提案は、ルートの名前空間を「assets」から別の名前に変更することです。しかし、これには多くの作業が必要になる場合があります。私はまだ他のより簡単な方法を知りません。

更新 @sevenseacat のコメントに感謝します。彼はもっと簡単な方法を指摘しました - アセットのルートを変更することです

config.assets.prefix = "/some_other_path"

参照: assets -path"> http://guides.rubyonrails.org/asset_pipeline.html#changeing-the-assets-path

于 2013-05-02T14:06:17.907 に答える