0

これまでのところ、バックエンド コード (小さなカスタム ワークフロー エンジン、Redis、職長など) だけで構成されている Rails アプリがあります。今日、最初のコントローラーをアプリケーションに追加しようとしましたが、新しいコントローラーをロードできません。

私が使用した:

rails generate controller CollectedData new --no-test-framework

そして戻ってきました:

  create  app/controllers/collected_data_controller.rb
   route  get "collected_data/new"
  invoke  erb
  create    app/views/collected_data
  create    app/views/collected_data/new.html.erb
  invoke  helper
  create    app/helpers/collected_data_helper.rb
  invoke  assets
  invoke    coffee
  create      app/assets/javascripts/collected_data.js.coffee
  invoke    scss
  create      app/assets/stylesheets/collected_data.css.scss

そして、私も走っrake routesてこれを得ました:

collected_data_new GET /collected_data/new(.:format) collected_data#new

しかしhttp://localhost:3000/collected_data/new、ブラウザに読み込むたびに、次のようになります。

Not Found: /collected_data/new

これが私のroutes.rbファイルの内容です:

Crows::Application.routes.draw do
  get "collected_data/new"

  # The priority is based upon order of creation:
  # first created -> highest priority.

  # Sample of regular route:
  #   match 'products/:id' => 'catalog#view'
  # Keep in mind you can assign values other than :controller and :action

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

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

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

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

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

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

  # You can have the root of your site routed with "root"
  # just remember to delete public/index.html.
  # root :to => 'welcome#index'

  # See how all your routes lay out with "rake routes"

  # This is a legacy wild controller route that's not recommended for RESTful applications.
  # Note: This route will make all actions in every controller accessible via GET requests.
  # match ':controller(/:action(/:id))(.:format)'
end

プロファイルの内容:

redis: redis-server config/redis/redis.conf
clock: bundle exec rake resque:scheduler --trace
cp_resp_poller: bundle exec rake environment resque:work QUEUE=cp_resp_poller
cp_req_sender: bundle exec rake environment resque:work QUEUE=cp_req_sender --trace
server: rails server

WEBrickの再起動も試しました。

更新: このコントローラー (または追加しようとした新しいコントローラー) を要求すると、Webrick が HTTP 404 を返すことに気付きました。

修正済み: この質問に対する私自身の回答を参照してください。

4

1 に答える 1

1

修正済み: config.ru ファイルを変更してこれを修正しました。

元のコンテンツは次のとおりです。

require ::File.expand_path('../config/environment',  __FILE__)
run Crows::Application

require 'resque/server'
run Rack::URLMap.new "/resque" => Resque::Server.new

Resque に関連する上記の最後の 2 行をコメントアウトして、コントローラが見つからない問題を修正しました。これらの最後の 2 行は、アプリケーションのワークフロー/バックエンド部分を開発しているときに追加され、Resque の Web ベースの管理インターフェイスを有効にしました。

更新: これで、Rails アプリ (およびその Web コントローラーなど) と Resque Web 管理インターフェイスが並行して実行されます。config.ru ファイルから最後の 2 行を削除し、routes.rb ファイルに次の行を追加して、これを機能させました。

resources :resque_web_admin
mount Resque::Server, :at => "/resque"
于 2013-08-13T16:38:14.510 に答える