Witam.
Mam problem z uruchomieniem aplikacji w środowisku produkcyjnym. Na serwerze jest ruby 1.8.7 i rails 2.3.5. Aktualnie mam ustawione dwie wersje:
http://akacja.wzks.uj.edu.pl/08_jewula/philoczytnik/ - wersja deweloperska
http://akacja.wzks.uj.edu.pl/08_jewula/philoczytnik_prod/ - wersja producyjna
Całość jest obsługiwana przez passengera. Wygenerowałem aplikację poprzez rails nazwa_aplikacji. Następnie ustawiłem bazę na mysql i stworzyłem trzy rusztowania: articles, magazines oraz issues. W trybie deweloperskim wszystko działa. Pod adresem głównym pojawia się strona domyślna, a kontrolery /articles, /magazines oraz /issues pokazują domyślne widoki (puste, gdyż nie ma jeszcze danych). Przełączenie się do trybu produkcyjnego powoduje, że zamiast strony pojawia się informacja o błędzie 404 (The page you were looking for doesn’t exist.).
Log produkcyjny pokazuje:
[code]Processing ApplicationController#index (for 87.207.187.14 at 2011-04-11 00:19:59) [GET]
ActionController::RoutingError (No route matches “_prod/magazines” with {:method=>:get}):
passenger (2.2.11) lib/phusion_passenger/rack/request_handler.rb:92:in process_request' passenger (2.2.11) lib/phusion_passenger/abstract_request_handler.rb:207:in
main_loop’
passenger (2.2.11) lib/phusion_passenger/railz/application_spawner.rb:418:in start_request_handler' passenger (2.2.11) lib/phusion_passenger/railz/application_spawner.rb:358:in
handle_spawn_application’
passenger (2.2.11) lib/phusion_passenger/utils.rb:184:in safe_fork' passenger (2.2.11) lib/phusion_passenger/railz/application_spawner.rb:354:in
handle_spawn_application’
passenger (2.2.11) lib/phusion_passenger/abstract_server.rb:352:in __send__' passenger (2.2.11) lib/phusion_passenger/abstract_server.rb:352:in
main_loop’
passenger (2.2.11) lib/phusion_passenger/abstract_server.rb:196:in start_synchronously' passenger (2.2.11) lib/phusion_passenger/abstract_server.rb:163:in
start’
passenger (2.2.11) lib/phusion_passenger/railz/application_spawner.rb:213:in start' passenger (2.2.11) lib/phusion_passenger/spawn_manager.rb:262:in
spawn_rails_application’
passenger (2.2.11) lib/phusion_passenger/abstract_server_collection.rb:126:in lookup_or_add' passenger (2.2.11) lib/phusion_passenger/spawn_manager.rb:256:in
spawn_rails_application’
passenger (2.2.11) lib/phusion_passenger/abstract_server_collection.rb:80:in synchronize' passenger (2.2.11) lib/phusion_passenger/abstract_server_collection.rb:79:in
synchronize’
passenger (2.2.11) lib/phusion_passenger/spawn_manager.rb:255:in spawn_rails_application' passenger (2.2.11) lib/phusion_passenger/spawn_manager.rb:154:in
spawn_application’
passenger (2.2.11) lib/phusion_passenger/spawn_manager.rb:287:in handle_spawn_application' passenger (2.2.11) lib/phusion_passenger/abstract_server.rb:352:in
send’
passenger (2.2.11) lib/phusion_passenger/abstract_server.rb:352:in main_loop' passenger (2.2.11) lib/phusion_passenger/abstract_server.rb:196:in
start_synchronously’
passenger (2.2.11) lib/phusion_passenger/abstract_server.rb:163:in start' passenger (2.2.11) lib/phusion_passenger/railz/application_spawner.rb:213:in
start’
passenger (2.2.11) lib/phusion_passenger/spawn_manager.rb:262:in spawn_rails_application' passenger (2.2.11) lib/phusion_passenger/abstract_server_collection.rb:126:in
lookup_or_add’
passenger (2.2.11) lib/phusion_passenger/spawn_manager.rb:256:in spawn_rails_application' passenger (2.2.11) lib/phusion_passenger/abstract_server_collection.rb:80:in
synchronize’
passenger (2.2.11) lib/phusion_passenger/abstract_server_collection.rb:79:in synchronize' passenger (2.2.11) lib/phusion_passenger/spawn_manager.rb:255:in
spawn_rails_application’
passenger (2.2.11) lib/phusion_passenger/spawn_manager.rb:154:in spawn_application' passenger (2.2.11) lib/phusion_passenger/spawn_manager.rb:287:in
handle_spawn_application’
passenger (2.2.11) lib/phusion_passenger/abstract_server.rb:352:in __send__' passenger (2.2.11) lib/phusion_passenger/abstract_server.rb:352:in
main_loop’
passenger (2.2.11) lib/phusion_passenger/abstract_server.rb:196:in `start_synchronously’
Rendering /home/epi/08_jewula/philoczytnik/public/404.html (404 Not Found)[/code]
Próbowałem zamienić plik config/environments/production.rb na development.rb. Próbowałem w pierwotnym production.rb dodać
config.serve_static_assets = true
plik routes.rb jest klasyczny, wygląda tak:
[code]ActionController::Routing::Routes.draw do |map|
map.resources :issues
map.resources :magazines
map.resources :issues
map.resources :articles
The priority is based upon order of creation: first created -> highest priority.
Sample of regular route:
map.connect ‘products/:id’, :controller => ‘catalog’, :action => ‘view’
Keep in mind you can assign values other than :controller and :action
Sample of named route:
map.purchase ‘products/:id/purchase’, :controller => ‘catalog’, :action => ‘purchase’
This route can be invoked with purchase_url(:id => product.id)
Sample resource route (maps HTTP verbs to controller actions automatically):
map.resources :products
Sample resource route with options:
map.resources :products, :member => { :short => :get, :toggle => :post }, :collection => { :sold => :get }
Sample resource route with sub-resources:
map.resources :products, :has_many => [ :comments, :sales ], :has_one => :seller
Sample resource route with more complex sub-resources
map.resources :products do |products|
products.resources :comments
products.resources :sales, :collection => { :recent => :get }
end
Sample resource route within a namespace:
map.namespace :admin do |admin|
# Directs /admin/products/* to Admin::ProductsController (app/controllers/admin/products_controller.rb)
admin.resources :products
end
You can have the root of your site routed with map.root – just remember to delete public/index.html.
map.root :controller => “welcome”
See how all your routes lay out with “rake routes”
Install the default routes as the lowest priority.
Note: These default routes make all actions in every controller accessible via GET requests. You should
consider removing or commenting them out if you’re using named routes and resources.
map.connect ‘:controller/:action/:id’
map.connect ‘:controller/:action/:id.:format’
end[/code]
Nie mam pomysłów dlaczego routing deweloperski działa, a produkcyjny nie działa i dlaczego tak dziwnie jest obcinany. Kiedy ścieżka prosta (http://akacja.wzks.uj.edu.pl/08_jewula/philoczytnik/) była uruchamiana w trybie produkcyjnym także występował ten błąd.