回形针不能保存在服务器上的生产环境中

时间:2013-09-01 16:15:49

标签: ruby-on-rails permissions paperclip production

回形针在生产中出错

当我创建一个 NEW 产品时,它会保存它,但在尝试显示时会重定向错误。 它重复了网址 (myweb.com/admin/admin/14)

并且必须是 (myweb.com/admin/14)

当我编辑现有产品时,它不会保存任何更改。

我知道问题在于回形针,因为当我在FORM中注释上传到数据库的行时,IMAGE可以完美地完成所有工作。

- 所以,它有一些保存图像的权限??? 我试图改变.htacces添加
SecFilterEngine关闭 SecFilterScanPOST关闭

并解除了apache中的MOD_SECURITY。但没有任何事情发生。不知道!!

模型

  attr_accessible :descripcion, :nombre, :pie, :precio, :stock, :pic, :pic_file_name

  has_attached_file :pic, :styles => { :intro => "300x300>", :medium => "200x200>", :thumb => "75x75>" }

错误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

任何想法???

我的控制器

  # GET /products/1
  # GET /products/1.json
  def show
    @product = Product.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.json { render :json => @product }
    end
  end

  # GET /products/new
  # GET /products/new.json
  def new
    @product = Product.new

    respond_to do |format|
      format.html # new.html.erb
      format.json { render :json => @product }
    end
  end

  # GET /products/1/edit
  def edit
    @product = Product.find(params[:id])
  end

  # POST /products
  # POST /products.json
  def create
    @product = Product.new(params[:product])

    respond_to do |format|
      if @product.save
        format.html { redirect_to @product, :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

  # PUT /products/1
  # PUT /products/1.json
  def update
    @product = Product.find(params[:id])

    respond_to do |format|
      if @product.update_attributes(params[:product])
        format.html { redirect_to @product, :notice => 'Producto actualizado CORRECTAMENTE.' }
        format.json { head :no_content }
      else
        format.html { render :action => "editar" }
        format.json { render :json => @product.errors, :status => :unprocessable_entity }
      end
    end
  end

我的ROUTES.rb

Sexytoys::Application.routes.draw do

  resources :products, :path => "admin"

1 个答案:

答案 0 :(得分:0)

您的控制器和路线文件怎么样?