在rails 4中的参数错误(太少的参数)仅适用于生产(heroku)环境中的respond_to调用

问题描述:

向控制器发布新照片时出现以下错误。我只有生产中的错误,本地工作正常。我查看了参数,并且在本地看起来相同,只有UTF8参数在本地有轻微不同的字符。在rails 4中的参数错误(太少的参数)仅适用于生产(heroku)环境中的respond_to调用

enter image description here

我的控制器。 35号线是完全respond_to do |format|

# POST /photos 
# POST /photos.json 
def create 
    @photo = Photo.new(photo_params) 
    @photo.user = current_user 

    respond_to do |format| 
    if @photo.save 
     format.html { redirect_to new_photo_path, notice: 'Photo was successfully created.' } 
     format.json { render :show, status: :created, location: @photo } 
    else 
     format.html { render :new } 
     format.json { render json: @photo.errors, status: :unprocessable_entity } 
    end 
    end 
end 

我的模型

class Photo < ActiveRecord::Base 
    dragonfly_accessor :image 
    belongs_to :user 

    validates :image, presence: true 
    validates_size_of :image, maximum: 500.kilobytes, 
    message: "should be no more than 500 KB", if: :image_changed? 

    validates_property :format, of: :image, in: [:jpeg, :jpg, :png, :bmp], case_sensitive: false, 
    message: "should be either .jpeg, .jpg, .png, .bmp", if: :image_changed? 
end 

蜻蜓配置是

require 'dragonfly' 

# Configure 
Dragonfly.app.configure do 
    protect_from_dos_attacks true 
    secret "92a3093304fd5b5ad0d1fa716caeae7b02aedd702127ead467f24f6b1526bd05" 

    url_format "/media/:job/:name" 

    Rails.logger.debug 'Root path: ' + Rails.root.join('public/system/dragonfly', Rails.env).inspect 
    if Rails.env.development? || Rails.env.test? 
    plugin :imagemagick, 
    convert_command: 'C:/Ruby200-x64/ImageMagic/convert', # defaults to "convert" 
    identify_command: 'C:/Ruby200-x64/ImageMagic/identify' # defaults to "identify" 
    else 
# datastore :s3, 
#  bucket_name: 'petowners', 
#  access_key_id: 'insert_key', 
#  secret_access_key: 'insert_key', 
#  url_scheme: 'https' 
    end 
    datastore :file, 
     root_path: Rails.root.join('public/system/dragonfly', Rails.env), 
     server_root: Rails.root.join('public') 
end 

# Logger 
Dragonfly.logger = Rails.logger 

# Mount as middleware 
Rails.application.middleware.use Dragonfly::Middleware 

# Add model functionality 
if defined?(ActiveRecord::Base) 
    ActiveRecord::Base.extend Dragonfly::Model 
    ActiveRecord::Base.extend Dragonfly::Model::Validations 
end 

我的路线是

resources :pets 
    resources :dogs, controller: 'pets', type: 'Dog' 
    resources :hamsters, controller: 'pets', type: 'Hamster' 
    resources :cats, controller: 'pets', type: 'Cat' 

    authenticated :user do 
    root 'users#newsfeed', :as => :authenticated_root 
    get '/profile/:id', :to => 'users#profile', :as => :user_profile 
    end 
    root to: 'visitors#index' 
    devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks" } 
    resources :users 
    resources :photos, only: [:new, :create] 
    get '/photos/new_multiple', to: 'photos#new_multiple', as: :new_photo_multiple 

我使用蜻蜓与同datatstore。 Rails的4.1.6

我删除

protect_from_dos_attacks true 

和它的工作