0

我有一个在我的开发环境中运行良好的应用程序。在生产中,保存或更新新产品时会出现一些路由错误。

我正在使用标准脚手架和回形针宝石。正如我所说,一切都在开发中运行良好。

这是我的控制器代码:

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。

但在生产上:

http://www.tuwebenlaweb2.com.ar/admin/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'

这是我的 rake 路线:

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

我的路线.rb

Sexytoys::Application.routes.draw 做

资源:产品,:路径=>“管理员”

#resources :products #resources :sexytoys #match ':controller(/:action(/:id(.:format)))'

根 :to => 'sexytoys#inicio'

得到'sexytoys' => 'sexytoys#inicio' 得到'productos' => 'sexytoys#productos' 得到'categorias' => 'products#categorias'

得到'galeria' =>'sexytoys#galeria'

得到'primerIma' =>'sexytoys#primerIma'

获取 'add_to_cart' => 'sexytoys#add_to_cart' 发布 'add_to_cart' => 'sexytoys#add_to_cart'

获取 'empty_cart' => 'sexytoys#empty_cart' 发布 'empty_cart' => 'sexytoys#empty_cart'

获取'增量' => 'sexytoys#increment' 发布'增量' => 'sexytoys#increment'

得到'减量' => 'sexytoys#decrement' 发布'减量' => 'sexytoys#decrement'

得到'结帐' => 'sexytoys#checkout' 发布'结帐' => 'sexytoys#checkout'

获取'订单' => 'sexytoys#order' 发布'订单' => 'sexytoys#order'

这可能是什么原因造成的?

谢谢华金

//////////

我在 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
4

0 回答 0