0

我在我的 Mac 上设置了 Rails 环境。

本地~/GitHub/Warehouse/

服务器http://localhost:3001/

这是我的/config/routes.rb

Warehouse::Application.routes.draw do

    resources :events
    resources :locations
    resources :categories
    resources :items

    get "home/index"
    root :to => "home#index"

end

我将我的应用程序放在服务器上的一个文件夹~/warehouse中。它有一个指向 的符号~/public_html/warehouse/链接~/warehouse/public

所以我的网址是: http ://showtime.www77.a2hosting.com/warehouse

我收到以下错误:

Started GET "/warehouse" for 184.175.153.98 at Sat Nov 24 21:47:24 -0500 2012

ActionController::RoutingError (No route matches [GET] "/warehouse"):
    vendor/bundle/ruby/1.8/gems/actionpack-3.2.9/lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
    vendor/bundle/ruby/1.8/gems/actionpack-3.2.9/lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
    vendor/bundle/ruby/1.8/gems/railties-3.2.9/lib/rails/rack/logger.rb:32:in `call_app'
    vendor/bundle/ruby/1.8/gems/railties-3.2.9/lib/rails/rack/logger.rb:16:in `call'
    vendor/bundle/ruby/1.8/gems/activesupport-3.2.9/lib/active_support/tagged_logging.rb:22:in `tagged'
    vendor/bundle/ruby/1.8/gems/railties-3.2.9/lib/rails/rack/logger.rb:16:in `call'
    vendor/bundle/ruby/1.8/gems/actionpack-3.2.9/lib/action_dispatch/middleware/request_id.rb:22:in `call'
    vendor/bundle/ruby/1.8/gems/rack-1.4.1/lib/rack/methodoverride.rb:21:in `call'
    vendor/bundle/ruby/1.8/gems/rack-1.4.1/lib/rack/runtime.rb:17:in `call'
    vendor/bundle/ruby/1.8/gems/activesupport-3.2.9/lib/active_support/cache/strategy/local_cache.rb:72:in `call'
    vendor/bundle/ruby/1.8/gems/rack-1.4.1/lib/rack/lock.rb:15:in `call'
    vendor/bundle/ruby/1.8/gems/rack-cache-1.2/lib/rack/cache/context.rb:136:in `forward'
    vendor/bundle/ruby/1.8/gems/rack-cache-1.2/lib/rack/cache/context.rb:245:in `fetch'
    vendor/bundle/ruby/1.8/gems/rack-cache-1.2/lib/rack/cache/context.rb:185:in `lookup'
    vendor/bundle/ruby/1.8/gems/rack-cache-1.2/lib/rack/cache/context.rb:66:in `call!'
    vendor/bundle/ruby/1.8/gems/rack-cache-1.2/lib/rack/cache/context.rb:51:in `call'
    vendor/bundle/ruby/1.8/gems/railties-3.2.9/lib/rails/engine.rb:479:in `call'
    vendor/bundle/ruby/1.8/gems/railties-3.2.9/lib/rails/application.rb:223:in `call'
    vendor/bundle/ruby/1.8/gems/railties-3.2.9/lib/rails/railtie/configurable.rb:30:in `send'
    vendor/bundle/ruby/1.8/gems/railties-3.2.9/lib/rails/railtie/configurable.rb:30:in `method_missing'
    passenger (3.0.15) lib/phusion_passenger/rack/request_handler.rb:96:in `process_request'
    passenger (3.0.15) lib/phusion_passenger/abstract_request_handler.rb:516:in `accept_and_process_next_request'
    passenger (3.0.15) lib/phusion_passenger/abstract_request_handler.rb:274:in `main_loop'
    passenger (3.0.15) lib/phusion_passenger/rack/application_spawner.rb:206:in `start_request_handler'
    passenger (3.0.15) lib/phusion_passenger/rack/application_spawner.rb:171:in `send'
    passenger (3.0.15) lib/phusion_passenger/rack/application_spawner.rb:171:in `handle_spawn_application'
    passenger (3.0.15) lib/phusion_passenger/utils.rb:470:in `safe_fork'
    passenger (3.0.15) lib/phusion_passenger/rack/application_spawner.rb:166:in `handle_spawn_application'
    passenger (3.0.15) lib/phusion_passenger/abstract_server.rb:357:in `__send__'
    passenger (3.0.15) lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop'
    passenger (3.0.15) lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously'
    passenger (3.0.15) lib/phusion_passenger/abstract_server.rb:180:in `start'
    passenger (3.0.15) lib/phusion_passenger/rack/application_spawner.rb:129:in `start'
    passenger (3.0.15) lib/phusion_passenger/spawn_manager.rb:253:in `spawn_rack_application'
    passenger (3.0.15) lib/phusion_passenger/abstract_server_collection.rb:132:in `lookup_or_add'
    passenger (3.0.15) lib/phusion_passenger/spawn_manager.rb:246:in `spawn_rack_application'
    passenger (3.0.15) lib/phusion_passenger/abstract_server_collection.rb:82:in `synchronize'
    passenger (3.0.15) lib/phusion_passenger/abstract_server_collection.rb:79:in `synchronize'
    passenger (3.0.15) lib/phusion_passenger/spawn_manager.rb:244:in `spawn_rack_application'
    passenger (3.0.15) lib/phusion_passenger/spawn_manager.rb:137:in `spawn_application'
    passenger (3.0.15) lib/phusion_passenger/spawn_manager.rb:275:in `handle_spawn_application'
    passenger (3.0.15) lib/phusion_passenger/abstract_server.rb:357:in `__send__'
    passenger (3.0.15) lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop'
    passenger (3.0.15) lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously'
    passenger (3.0.15) helper-scripts/passenger-spawn-server:99

我的 routes.rb 表应该是什么样的?我对此感到困惑。请让我知道我应该做些什么来完成这项工作。先感谢您!

4

2 回答 2

1

尝试改变你的config.ru

map "/warehouse" do
  run Warehouse::Application
end

这会将您的应用程序和机架中间件安装到指定的路径或 URI 及其下的所有子路径,因此您的路由应该可以正常工作。如果您的资产有问题,请config.action_controller.asset_host在 config/environments 中的环境配置文件中进行调整。

于 2012-11-25T10:22:25.987 回答
0

尝试使用命名空间。你还需要

namepace :warehouse do
  resources ....
end

root_to '仓库#pages#home'

于 2012-11-25T18:55:41.423 回答