paperclip

Using the Rails Environment URL in a MODEL with paperclip

流过昼夜 提交于 2020-01-04 05:19:48
问题 in my users model I have a paperclip setup like this: has_attached_file :profile_pic, :styles => {:large => "300x300>", :medium => "150x150>", :small => "50x50#", :thumb => "30x30#" }, :default_style => :thumb, :default_url => '/images/:attachment/default_:style.png', How do I make the default URL, include the full URL? http://0.0.0.0:3000/images/:attachment/default_:style.png or http://sitename.com/images/:attachment/default_:style.png 回答1: In Rails 3 add: include Rails.application.routes

Using the Rails Environment URL in a MODEL with paperclip

醉酒当歌 提交于 2020-01-04 05:19:07
问题 in my users model I have a paperclip setup like this: has_attached_file :profile_pic, :styles => {:large => "300x300>", :medium => "150x150>", :small => "50x50#", :thumb => "30x30#" }, :default_style => :thumb, :default_url => '/images/:attachment/default_:style.png', How do I make the default URL, include the full URL? http://0.0.0.0:3000/images/:attachment/default_:style.png or http://sitename.com/images/:attachment/default_:style.png 回答1: In Rails 3 add: include Rails.application.routes

Google Cloud Storage requests are slow using Paperclip and Rails

坚强是说给别人听的谎言 提交于 2020-01-03 21:08:35
问题 I have a Rails application that uses Google Cloud Storage for images. Each view has approximately 8 image and when a user tries to load the page it takes more than 5 seconds to complete because of requests to GCS. Requests are made by Paperclip with the following config: config.paperclip_defaults = { storage: :fog, fog_credentials: { google_storage_access_key_id: myAccessKey, google_storage_secret_access_key: mySecretKey, provider: 'Google' }, fog_public: true, fog_directory: 'mybucket' } In

amazon aws-s3 access denied error

帅比萌擦擦* 提交于 2020-01-03 20:07:32
问题 I wanted to integrate amazon s3 service with my rails application. I am using paperclip(2.3.6) gem and aws-s3(0.6.2) gem for this. but as the user uploads a file, It throws an error Access denied. I am able to put and get the file if i am trying from rails console. using the same credentials. 回答1: Did you set up the ACL permissions ? http://www.bucketexplorer.com/ is a good tool for it. There are several S3 clients in all OS's. 来源: https://stackoverflow.com/questions/4322187/amazon-aws-s3

Rails 4, Paperclip 4.2.1 give error with binary file upload

左心房为你撑大大i 提交于 2020-01-03 19:32:27
问题 I have following setup with rails 4 and paperclip 4.2.1 class Post< ActiveRecord::Base has_attached_file :key allowed_content_type = ['text/plain', 'text/rtf', 'text/richtext', 'application/txt', 'application/octet-stream'] validates_attachment_content_type :key, :content_type => allowed_content_type, :message=> "Only #{allowed_content_type} is allowed" I have this in my application.rb <body data-controller="<%= controller.controller_path %>" data-action="<%= controller.action_name %>" data

Rails 4, Paperclip 4.2.1 give error with binary file upload

自闭症网瘾萝莉.ら 提交于 2020-01-03 19:32:10
问题 I have following setup with rails 4 and paperclip 4.2.1 class Post< ActiveRecord::Base has_attached_file :key allowed_content_type = ['text/plain', 'text/rtf', 'text/richtext', 'application/txt', 'application/octet-stream'] validates_attachment_content_type :key, :content_type => allowed_content_type, :message=> "Only #{allowed_content_type} is allowed" I have this in my application.rb <body data-controller="<%= controller.controller_path %>" data-action="<%= controller.action_name %>" data

Rails with Paperclip ignore empty attachments

被刻印的时光 ゝ 提交于 2020-01-03 12:46:01
问题 I am using paperclip with rails and it works fine, however my problem is when updating if the i don't reselect the image, then it saves the record as nil. Here is my code: <div class="form-group"> <div class="media"> <%= image_tag program_avatar(b), :id => 'avatar', :class => 'thumbnail media-object pull-left', :height => 100, :width => 100 %> <div class="media-body padding-top-40"> <%= b.file_field :avatar, :class => 'file-upload' %> </div> </div> </div> <div class="form-group"> <div class=

Rails 4, Paperclip and polymorphic association

。_饼干妹妹 提交于 2020-01-03 05:01:08
问题 I have 2 models: News and Uploadedfile class News < ActiveRecord::Base has_many :uploadedfiles, as: :parent attr_accessible :title, :content, :author end class Uploadedfile < ActiveRecord::Base belongs_to :parent, polymorphic: true has_attached_file :url attr_accessible :url_file_name, :url_content_type, :url_file_size, :url_updated_at end And form: <%= form_for(@news) do |f| %> <div class="field"> <%= f.fields_for :uploadedfile, f.uploadedfile.new do |uf| %> <%= uf.label :url %><br> <%= uf

RMagick mask Paperclip image attachment

假装没事ソ 提交于 2020-01-03 03:54:23
问题 I am using Paperclip to attach image files to an object and all is well but I'd also like to mask (preferably only one of the image style – main_feature) the image upon upload. I'm able to save my masked image using masked_image.write('result.png') but can't seem to get it to update the image attribute for Paperclip. With the following code I get this error: No handler found for /var/folders/q1/xf59whv514lgw_xr10hb208m0000gn/T/gaither-nomask20130312-80235-yaj1s7.png PNG 1020x470 1020x470+0+0

Issue with Paperclip/S3 in Rails 3.2.5 “cannot load such file — aws-sdk”

家住魔仙堡 提交于 2020-01-02 19:29:06
问题 Image Uploading was working fine, but when I tried switching it to S3, it started throwing an error. I get the following error when I try to create a new image upload: cannot load such file -- aws-sdk (You may need to install the aws-sdk gem) Relevant gems: gem 'rails', '3.2.5' gem 'paperclip' gem 'aws-sdk' config/s3.yml: development: bucket: bucketname access_key_id: # secret_access_key: # test: bucket: bucketname access_key_id: # secret_access_key: # image_upload.rb: has_attached_file