have issue with code that rise just now but work before i got this code:
有问题的代码刚刚上升,但在我得到这段代码之前工作:
-
Controller
调节器
def new errors ||= Array.new if params[:file].blank? errors.push(I18n.t("errors.messages.file_error")) end if errors.length == 0 # begin # binding.pry assetObject = Assets.new(:asset=>params[:file]) assetObject.save! image = assetObject.asset.url(:small) imageExpBanner = assetObject.asset.url(:expBanner) data = OpenStruct.new({ id: assetObject.id, uri: image, expBannerUri: imageExpBanner }) @responseObject = OpenStruct.new({ status: true, errors: [], code: API_CODE_ERRORS['Services']['Global']['success'], objectData: data }) render :template => 'api/v1/general/assets/new' ,:handlers => [:rabl],:formats => [:json] #rescue => e # binding.pry # logger.error e # errors.push(I18n.t("errors.messages.file_size_error")) # render :json => Api::Init.ShowErrorJson(API_CODE_ERRORS['Services']['Global']['file_size'],I18n.t("errors.messages.feelike.input_error"), errors).to_json # end else render :json => Api::Init.ShowErrorJson(API_CODE_ERRORS['Services']['Global']['formInputError'],I18n.t("errors.messages.feelike.input_error"), errors).to_json end
end
结束
-
Model
模型
class Assets < ActiveRecord::Base
class Assets
attr_accessible :asset,:asset_content_type, :asset_file_name, :asset_file_size
has_attached_file :asset, :styles => {
:small => "150x150>" ,
:expBanner => "620x184",
:expBigImage => "304X304",
:expSmallImage => "148X148",
:storage => :s3,
:s3_credentials => "#{Rails.root}/config/s3.yml",
:path => "/uploads/:style/:id/:hash.:extension",
:url => :s3_eu_url ,
:hash_secret => "longSecretString"
}
validates :asset, :attachment_presence => true
validates_attachment_size :asset, :less_than => 10.megabytes
validates_attachment_content_type :asset, :content_type => ['image/jpeg','image/gif', 'image/png']
end
now its return me this error:
现在它给我这个错误:
Started POST "/api/general/assets/new" for 127.0.0.1 at 2013-03-28 11:32:19 +0200
Processing by Api::V1::General::AssetsController#new as JSON
Parameters: {"file"=>#<ActionDispatch::Http::UploadedFile:0x007fc39853ac10 @original_filename="usidentification.jpg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"file\"; filename=\"usidentification.jpg\"\r\nContent-Type: image/jpeg\r\n", @tempfile=#<File:/tmp/RackMultipart20130328-15640-1hdj5ee>>}
WARNING: Can't verify CSRF token authenticity
Completed 500 Internal Server Error in 3491ms
TypeError - can't dup Symbol:
(gem) paperclip-3.4.0/lib/paperclip/attachment.rb:176:in `block in styles'
(gem) paperclip-3.4.0/lib/paperclip/attachment.rb:175:in `styles'
(gem) paperclip-3.4.0/lib/paperclip/attachment.rb:421:in `post_process_styles'
(gem) paperclip-3.4.0/lib/paperclip/attachment.rb:415:in `block (2 levels) in post_process'
/usr/local/rvm/gems/ruby-1.9.3-p327@global/gems/activesupport-3.2.9/lib/active_support/callbacks.rb:403:in `_run__3148635882202100687__asset_post_process__2098004068316531280__callbacks'
/usr/local/rvm/gems/ruby-1.9.3-p327@global/gems/activesupport-3.2.9/lib/active_support/callbacks.rb:405:in `__run_callback'
/usr/local/rvm/gems/ruby-1.9.3-p327@global/gems/activesupport-3.2.9/lib/active_support/callbacks.rb:385:in `_run_asset_post_process_callbacks'
/usr/local/rvm/gems/ruby-1.9.3-p327@global/gems/activesupport-3.2.9/lib/active_support/callbacks.rb:81:in `run_callbacks'
(gem) paperclip-3.4.0/lib/paperclip/callbacks.rb:26:in `run_paperclip_callbacks'
(gem) paperclip-3.4.0/lib/paperclip/attachment.rb:414:in `block in post_process'
/usr/local/rvm/gems/ruby-1.9.3-p327@global/gems/activesupport-3.2.9/lib/active_support/callbacks.rb:403:in `_run__3148635882202100687__post_process__2098004068316531280__callbacks'
/usr/local/rvm/gems/ruby-1.9.3-p327@global/gems/activesupport-3.2.9/lib/active_support/callbacks.rb:405:in `__run_callback'
/usr/local/rvm/gems/ruby-1.9.3-p327@global/gems/activesupport-3.2.9/lib/active_support/callbacks.rb:385:in `_run_post_process_callbacks'
/usr/local/rvm/gems/ruby-1.9.3-p327@global/gems/activesupport-3.2.9/lib/active_support/callbacks.rb:81:in `run_callbacks'
(gem) paperclip-3.4.0/lib/paperclip/callbacks.rb:26:in `run_paperclip_callbacks'
(gem) paperclip-3.4.0/lib/paperclip/attachment.rb:413:in `post_process'
(gem) paperclip-3.4.0/lib/paperclip/attachment.rb:108:in `assign'
now what dose it means TypeError - can't dup Symbol now i try few ways fix at and got this every time need help in this
现在是什么剂量它意味着TypeError - 不能重复符号现在我尝试几个方法修复,并得到这一次每次都需要帮助
1 个解决方案
#1
0
found the issue was there
发现问题就在那里
has_attached_file :asset, :styles => {
:small => "150x150>" ,
:expBanner => "620x184",
:expBigImage => "304X304",
:expSmallImage => "148X148",
},
:storage => :s3,
:s3_credentials => "#{Rails.root}/config/s3.yml",
:path => "/uploads/:style/:id/:hash.:extension",
:url => :s3_eu_url ,
:hash_secret => "longSecretString"
#1
0
found the issue was there
发现问题就在那里
has_attached_file :asset, :styles => {
:small => "150x150>" ,
:expBanner => "620x184",
:expBigImage => "304X304",
:expSmallImage => "148X148",
},
:storage => :s3,
:s3_credentials => "#{Rails.root}/config/s3.yml",
:path => "/uploads/:style/:id/:hash.:extension",
:url => :s3_eu_url ,
:hash_secret => "longSecretString"