2014-10-02 3 views
1

컨트롤러에 새 사진을 게시 할 때 다음과 같은 오류가 발생합니다. 난 단지 생산에 오류가 로컬로 잘 작동합니다. 나는 params를 보았고 지역적으로 보면 UTF8 params만이 로컬에서 약간 다른 chars를 가지고있는 것처럼 보였다.raul (인수가 너무 적음) 레일 4에서 respond_to는 생산 (heroku) 환경에서만 호출

enter image description here

내 컨트롤러입니다. 선 (35) 내 경로가 나는 같은과 잠자리를 사용하고

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 

입니다 respond_to do |format|가 잠자리 설정이

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 

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 

내 모델이되어

# 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 

정확히 데이터 저장소. 레일 4.1.6

답변

0

나는

protect_from_dos_attacks true 

을 제거하고이

근무