我的应用程序在我的开发环境中运行良好。在生产时,它会在保存新产品或更新产品时出现一些路由错误。
我正在使用标准脚手架和回形针宝石。正如我所说,在开发过程中一切都很好。
这是我的控制器代码:
def create
@product = Product.new(params[:product])
respond_to do |format|
if @product.save
format.html { redirect_to products_path, :notice => 'El producto fue agregado CORRECTAMENTE.' }
format.json { render :json => @product, :status => :created, :location => @product }
else
format.html { render :action => "new" }
format.json { render :json => @product.errors, :status => :unprocessable_entity }
end
end
end
当我在开发环境中创建新产品时,它会重定向以显示带有id的新产品。
http://localhost:3000/admin/55
在添加新产品后重定向到新产品时,这是开发中的网址。
但是关于制作:
它改变了路由(url中有一个额外的admin
或者其他东西,它在production.log中给了我这个错误:
Started GET "/admin/admin/39" for 186.108.188.126 at Sun Aug 25 18:03:34 -0400 2013
ActionController::RoutingError (No route matches [GET] "/admin/admin/39"):
vendor/bundle/ruby/1.8/gems/actionpack-3.2.3/lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
这是我的佣金路线:
juako@juako:~/Dropbox/sexytoys$ rake routes
products GET /admin(.:format) products#index
POST /admin(.:format) products#create
new_product GET /admin/new(.:format) products#new
edit_product GET /admin/:id/edit(.:format) products#edit
product GET /admin/:id(.:format) products#show
PUT /admin/:id(.:format) products#update
DELETE /admin/:id(.:format) products#destroy
root / sexytoys#inicio
sexytoys GET /sexytoys(.:format) sexytoys#inicio
productos GET /productos(.:format) sexytoys#productos
categorias GET /categorias(.:format) products#categorias
galeria GET /galeria(.:format) sexytoys#galeria
primerIma GET /primerIma(.:format) sexytoys#primerIma
add_to_cart GET /add_to_cart(.:format) sexytoys#add_to_cart
POST /add_to_cart(.:format) sexytoys#add_to_cart
empty_cart GET /empty_cart(.:format) sexytoys#empty_cart
POST /empty_cart(.:format) sexytoys#empty_cart
increment GET /increment(.:format) sexytoys#increment
POST /increment(.:format) sexytoys#increment
decrement GET /decrement(.:format) sexytoys#decrement
POST /decrement(.:format) sexytoys#decrement
checkout GET /checkout(.:format) sexytoys#checkout
POST /checkout(.:format) sexytoys#checkout
order GET /order(.:format) sexytoys#order
POST /order(.:format) sexytoys#order
my routes.rb
Sexytoys :: Application.routes.draw做
资源:products,:path => “管理员”
#resources:products #resources:sexytoys #match ':控制器(/:动作(/:ID(:格式)))'
root:to => 'sexytoys#INICIO'
获取'sexytoys'=> 'sexytoys#inicio'get'productos'=> 'sexytoys#PRODUCTOS' 获取'分类'=>的产品#categorias'
获取'galeria'=> 'sexytoys#GALERIA'
获取'primerIma'=> 'sexytoys#primerIma'
获取'add_to_cart'=> 'sexytoys #add_to_cart'post'add_to_cart'=> 'sexytoys#add_to_cart'
获取'empty_cart'=> 'sexytoys#empty_cart'发布'empty_cart'=> 'sexytoys#empty_cart'
获取'增量'=> 'sexytoys#increment'post'increed'=> 'sexytoys#增量'
获取'减量'=> 'sexytoys#decrement'post'decrement'=> 'sexytoys#递减'
获取'结帐'=> 'sexytoys#checkout'post'checkout'=> 'sexytoys#结帐'
获取'订单'=> 'sexytoys #order'post'order'=> 'sexytoys#顺序'
导致这种情况的原因是什么?
由于 华金
//////////
我在PRODUCTION.LOG中的错误
感谢
Started GET "/admin/new" for 190.226.107.164 at Thu Aug 29 07:53:46 -0400 2013
Processing by ProductsController#new as HTML
Rendered products/_header.html.haml (3.9ms)
Rendered products/_form.html.haml (12.2ms)
Rendered products/new.html.haml (21.6ms)
Completed 200 OK in 37ms (Views: 35.7ms | ActiveRecord: 0.0ms)
Started POST "/admin/admin" for 190.226.107.164 at Thu Aug 29 07:53:50 -0400 2013
Processing by ProductsController#create as HTML
Parameters: {"commit"=>"Guardar Cambios", "product"=>{"precio"=>"", "descripcion"=>"dsfds", "pie"=>"intro", "nombre"=>"dfsdfs"}, "authenticity_token"=>"MedLwu+JhiqOL6xKr0HS7zkCvBrkA54+EBeyPEZqTgo=", "utf8"=>"✓"}
[paperclip] Saving attachments.
Redirected to http://www.tuwebenlaweb2.com.ar/admin/admin/41
Completed 302 Found in 17ms (ActiveRecord: 10.7ms)
Started GET "/admin/admin/41" for 190.226.107.164 at Thu Aug 29 07:53:50 -0400 2013
ActionController::RoutingError (No route matches [GET] "/admin/admin/41"):
vendor/bundle/ruby/1.8/gems/actionpack-3.2.3/lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
vendor/bundle/ruby/1.8/gems/actionpack-3.2.3/lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
vendor/bundle/ruby/1.8/gems/railties-3.2.3/lib/rails/rack/logger.rb:26:in `call_app'
vendor/bundle/ruby/1.8/gems/railties-3.2.3/lib/rails/rack/logger.rb:16:in `call'
vendor/bundle/ruby/1.8/gems/actionpack-3.2.3/lib/action_dispatch/middleware/request_id.rb:22:in `call'
vendor/bundle/ruby/1.8/gems/rack-1.4.5/lib/rack/methodoverride.rb:21:in `call'
vendor/bundle/ruby/1.8/gems/rack-1.4.5/lib/rack/runtime.rb:17:in `call'
vendor/bundle/ruby/1.8/gems/activesupport-3.2.3/lib/active_support/cache/strategy/local_cache.rb:72:in `call'
vendor/bundle/ruby/1.8/gems/rack-1.4.5/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.3/lib/rails/engine.rb:479:in `call'
vendor/bundle/ruby/1.8/gems/railties-3.2.3/lib/rails/application.rb:220:in `call'
vendor/bundle/ruby/1.8/gems/railties-3.2.3/lib/rails/railtie/configurable.rb:30:in `send'
vendor/bundle/ruby/1.8/gems/railties-3.2.3/lib/rails/railtie/configurable.rb:30:in `method_missing'
passenger (3.0.18) lib/phusion_passenger/rack/request_handler.rb:96:in `process_request'
passenger (3.0.18) lib/phusion_passenger/abstract_request_handler.rb:516:in `accept_and_process_next_request'
passenger (3.0.18) lib/phusion_passenger/abstract_request_handler.rb:274:in `main_loop'
passenger (3.0.18) lib/phusion_passenger/rack/application_spawner.rb:206:in `start_request_handler'
passenger (3.0.18) lib/phusion_passenger/rack/application_spawner.rb:171:in `send'
passenger (3.0.18) lib/phusion_passenger/rack/application_spawner.rb:171:in `handle_spawn_application'
passenger (3.0.18) lib/phusion_passenger/utils.rb:470:in `safe_fork'
passenger (3.0.18) lib/phusion_passenger/rack/application_spawner.rb:166:in `handle_spawn_application'
passenger (3.0.18) lib/phusion_passenger/abstract_server.rb:357:in `__send__'
passenger (3.0.18) lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop'
passenger (3.0.18) lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously'
passenger (3.0.18) lib/phusion_passenger/abstract_server.rb:180:in `start'
passenger (3.0.18) lib/phusion_passenger/rack/application_spawner.rb:129:in `start'
passenger (3.0.18) lib/phusion_passenger/spawn_manager.rb:253:in `spawn_rack_application'
passenger (3.0.18) lib/phusion_passenger/abstract_server_collection.rb:132:in `lookup_or_add'
passenger (3.0.18) lib/phusion_passenger/spawn_manager.rb:246:in `spawn_rack_application'
passenger (3.0.18) lib/phusion_passenger/abstract_server_collection.rb:82:in `synchronize'
passenger (3.0.18) lib/phusion_passenger/abstract_server_collection.rb:79:in `synchronize'
passenger (3.0.18) lib/phusion_passenger/spawn_manager.rb:244:in `spawn_rack_application'
passenger (3.0.18) lib/phusion_passenger/spawn_manager.rb:137:in `spawn_application'
passenger (3.0.18) lib/phusion_passenger/spawn_manager.rb:275:in `handle_spawn_application'
passenger (3.0.18) lib/phusion_passenger/abstract_server.rb:357:in `__send__'
passenger (3.0.18) lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop'
passenger (3.0.18) lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously'
passenger (3.0.18) helper-scripts/passenger-spawn-server:99