Tag: 回形针

Paperclip Force下载

希望任何人都可以提供帮助! 利用Paperclip将文件上传到应用程序,这是我需要涵盖的两件事。 1)链接到File for Download的最佳方式是什么,我目前正在链接到公共文件夹,但它不是最好的选项,因为它显示了我不想要的URL。 想想也许一个button_to调用不确定它是否已经构建到Paperclip中。 选项。 2)当完成上述操作后,浏览器需要强制下载而不仅仅是打开文件,或者至少给用户打开或保存标准的firefox选项。 请帮助米勒!

在aws-s3 gem和right_aws gem之间的Rails Paperclip冲突。 怎么解决?

对于新的应用程序,我想使用paperclip将文件存储到S3。 我已经为另一个应用程序安装了aws-s3 gem。 这似乎会导致一些问题,因为Paperclip应该使用right_aws但是试图使用aws-s3 gem。 但我不想从我的系统中删除aws-s3 gem。 有没有办法解决这个冲突? 也许通过强制回形针使用right_aws? 或者通过更改配置? 我的设置 # enviroment.rb config.gem ‘right_aws’ # my model with the attachment has_attached_file :thumbnail, :styles => { :thumb => “160×120>” }, :storage => :s3, :s3_credentials => “#{RAILS_ROOT}/config/amazons3.yml”, :path => “:provider/:attachment/:id_:style.:extension” # config/amazons3.yml development: bucket: bucketname access_key_id: secret secret_access_key: secret test: bucket: bucketname access_key_id: secret secret_access_key: secret […]

带有S3 on Rails 3的回形针/未初始化的常量AWS :: S3 :: Connection

我正在尝试使用paperclip将文件上传到s3,并在创建新对象并引用变量时出现此错误: 安装了aws-s3 gem s3.yml文件具有正确的凭据 即: a = Attachment.new a.file NameError: uninitialized constant AWS::S3::Connection from /Library/Ruby/Gems/1.8/gems/aws-s3-0.6.2/lib/aws/s3/extensions.rb:206:in `const_missing’ from /Library/Ruby/Gems/1.8/gems/aws-s3-0.6.2/lib/aws/s3.rb:32 from /Library/Ruby/Gems/1.8/gems/aws-s3-0.6.2/lib/aws/s3.rb:31:in `class_eval’ from /Library/Ruby/Gems/1.8/gems/aws-s3-0.6.2/lib/aws/s3.rb:31 from /Library/Ruby/Gems/1.8/gems/paperclip-2.3.3/lib/paperclip/storage.rb:131:in `extended’ from /Library/Ruby/Gems/1.8/gems/paperclip-2.3.3/lib/paperclip/attachment.rb:269:in `extend’ from /Library/Ruby/Gems/1.8/gems/paperclip-2.3.3/lib/paperclip/attachment.rb:269:in `initialize_storage’ from /Library/Ruby/Gems/1.8/gems/paperclip-2.3.3/lib/paperclip/attachment.rb:51:in `initialize’ from /Library/Ruby/Gems/1.8/gems/paperclip-2.3.3/lib/paperclip.rb:372:in `new’ from /Library/Ruby/Gems/1.8/gems/paperclip-2.3.3/lib/paperclip.rb:372:in `attachment_for’ from /Library/Ruby/Gems/1.8/gems/paperclip-2.3.3/lib/paperclip.rb:270:in `file’ from (irb):6 这是Attachment模型的样子: class Attachment :s3, :s3_credentials => “#{RAILS_ROOT}/config/s3.yml”, :path => […]

在Ruby on Rails 3上上传多个文件

我想将多张图片上传到我的Rails 3应用程序。 我目前正在使用Paperclip上传图片,并且我将一些后期处理操作分配给模型Photo。 我在网上看到了一些示例(集成了uploadify,swfupload或其他一些库),但没有一个非常详细,每个都错过了一些步骤。 最简单的方法是什么?

Paperclip会自动清理文件名吗?

我正在使用Thoughtbot的Paperclip gem来处理文件上传。 我发现当我上传文件名中包含空格的文件时,它会被替换为下划线的空格存储。 非常好。 我也尝试上传一个像~等特殊字符的文件,它们都被替换为下划线。 大。 正是我想要的。 但为什么会这样呢? 我在模特中所做的一切都是…… has_attached_file( file_somefile, :path => “:rails_root/public/system/other/path/elements/:basename.:extension” ) 这是Paperclip的默认行为吗?

Paperclip / Passenger NotIdentifiedByImageMagickError:

当我尝试在我的本地机器上使用Paperclip在Ruby on Rails上传照片时,它可以很好地工作。 当我尝试使用Paperclip在我们的Linux( CentOS 5.2)服务器上使用Apache和Phusion Passenger在Ruby on Rails上传照片时,我得到: 2 errors prohibited this user from being saved There were problems with the following fields: – Avatar /tmp/stream20091026-21120-1qdbnul-0 is not recognized by the ‘identify’ command. – Avatar /tmp/stream20091026-21120-1qdbnul-0 is not recognized by the ‘identify’ command. 我尝试添加: Paperclip.options[:command_path] = “/usr/local/bin” 到production.rb但它并没有什么区别。 在日志文件中,我收到以下错误: 参数:{“commit”=>“Upload”,“action”=>“update”,“_ method”=>“put”,“authenticity_token”=>“419410afc22737cd2f6b6096a95327db76a48ba9”,“controller”=>“users”,“user” “=> {”avatar“=>#}} [paperclip]保存附件。 […]

回形针:一个模型中有多个“has_attached_file”

我模型的片段: attr_accessible :package1_file_name, :package2_file_name has_attached_file :package1 has_attached_file :package2 来自我的_form(简化版): { :multipart => true, :id => “fileupload” }) do |f| %> 问题是paperclip将为数据库中的每个文件插入两个单独的条目。 但是,我希望它只插入一个条目,因为我的表中有两个单独的字段: package1_file_name , package2_file_name 。 有没有办法实现这个目标? 谢谢! 对于Christian Varga: 也许我不应该简化原始问题中的代码,但在使用jQuery file upload插件后,我的视图实际上看起来像这样: 其中upload是当前模型的子模型 我不确定multipart是否使两个文件字段像单独的附件,但我试图将这两个附件合并为一个。

Rails Paperclip:update与update_attributes

当我尝试通过paperclip gem为我的用户模型(在avatar属性下)上传图像时,我意识到了一些非常奇怪的事情。 出于某种原因,User.update和@ user.update_attributes的行为有所不同。 有谁知道为什么会这样? #using @user.update_attributes(user_avatar_params) def update_profile_pic @user = User.find(params[:id]) @user.update_attributes(user_avatar_params) puts @user.avatar_file_name.nil? # prints false as expected respond_to do |format| format.html { redirect_to :back } format.js end end #using User.update(@user.id, user_avatar_params) def update_profile_pic @user = User.find(params[:id]) User.update(@user.id, user_avatar_params) puts @user.avatar_file_name.nil? # prints true although successfully saves respond_to do |format| format.html { redirect_to […]

Rails缺少图像

我目前正在使用paperclip将图像上传到我的rails应用程序。 这可能是一个非常简单的修复,但我如何或在哪里保存丢失的图像? 这是由于没有任何丢失的图像而产生的错误。 我该如何改变? ActionController::RoutingError (No route matches “/photos/normal/missing.png”):

缩放图像时,PaperClip错误NotIdentifiedByImageMagickError

几天来,我一直在反对这个问题。 最近,我的图片上传器已停止正常工作。 我已经研究了几种可能性,但没有一种建议的解决方案适用于我的情况。 错误消息是: # 以下是详细信息: Mac OS X 10.8.3 ImageMagick 6.8.4-4 2013-03-29 libtool => / usr / bin / libtool Rails 3.2.13 Ruby 1.9.3p194 development.rb包含适当的路径(我已经validation使用which identify是正确的) Paperclip.options[:command_path] = “/usr/local/bin/” Gemfile.lock (相关部分) paperclip (3.4.1) activemodel (>= 3.0.0) activerecord (>= 3.0.0) activesupport (>= 3.0.0) cocaine (~> 0.5.0) MODEL(我正在更新教室对象,但图片位于位置模型中。 (Classroom has_one :location, :as => :locatable) 型号location.rb class […]