paperclip

NoMethodError: undefined method `has_attached_file'

混江龙づ霸主 提交于 2019-12-10 03:41:48
问题 Paperclip produces this error, after checking out the plugin's rails3 branch. My Gemfile has following line: gem 'paperclip', :git => 'http://github.com/thoughtbot/paperclip.git', :branch => 'rails3' And the error message is: NoMethodError: undefined method `has_attached_file' for #<Class:0x2a50530> 回答1: Update 06-21-10: the thoughtbot version has been fixed. I had to add Paperclip::Railtie.insert to my application.rb at the end of class Application < Rails::Application to get it to work

Rails Paperclip: update vs. update_attributes

心已入冬 提交于 2019-12-10 00:38:17
问题 I realized something quite strange when attempting to upload an image via the paperclip gem for my user model (under the avatar attribute). For some reason there User.update and @user.update_attributes behaves differently. Does anyone know why this is so? #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

Rails Paperclip : Is there any option to save the uploaded file outside of the public folder?

99封情书 提交于 2019-12-09 23:25:32
问题 I am using paperclip gem for uploading. And i want to save the uploaded file/image outside of the public folder. If you have any idea please share. 回答1: Actually there is many. The 'public' option is just to be able to test easily. For your production server, paperclip gives three options: File Storage S3 Storage (via aws-sdk) Fog Storage File storage can be configured to go to any folder you want with something like: config.paperclip_defaults = { :path => "/yourfolder/:basename.:extension" }

can you pass self to lambda in rails?

这一生的挚爱 提交于 2019-12-09 22:58:34
问题 I want to define a class method that has access to a local variable. So this would be different for each instance of the class. I know you can make a class method dynamic with lambda like when you use it with named_scope. But can this be done for values that are specific to an instance? In detail it is the has_attached_file method for the paperclip plugin in rails. I want to pass a lambda for the styles hash so that the image styles can be based off of attributes of the object stored in the

Secure paperclip urls only for secure pages

安稳与你 提交于 2019-12-09 15:07:02
问题 I'm trying to find the best way to make paperclip urls secure, but only for secure pages. For instance, the homepage, which shows images stored in S3, is http://mydomain.com and the image url is http://s3.amazonaws.com/mydomainphotos/89/thisimage.JPG?1284314856. I have secure pages like https://mydomain.com/users/my_stuff/49 that has images stored in S3, but the S3 protocol is http and not https, so the user gets a warning from the browser saying that some elements on the page are not secure,

Duplicate column name error when running migration

左心房为你撑大大i 提交于 2019-12-09 12:26:30
问题 Whenever I run a migration in my Rails app, I get an error from SQLite3: SQLite3::SQLException: duplicate column name: photo_file_name: ALTER TABLE "users" ADD "photo_file_name" varchar(255) I already have a "Add Photo to User" migration. Here it is: class AddAttachmentPhotoToUsers < ActiveRecord::Migration def self.up change_table :users do |t| t.has_attached_file :photo end end def self.down drop_attached_file :users, :photo end end And here is the user migration: class CreateUsers <

Paperclip Errno::EACCES (Permission denied - /system)

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-09 11:03:15
问题 My production environment is : ruby 1.9.2-p320 , rails 3.2.7, paperclip 3.1.4, mysql, Ubuntu 8.10 x86 64bit. I have a Errno:EACCES Permission denied /system error when i try to upload a file with paperclip. Useless to say that locally this doesn't happen. I checked the public directory permissions and it's 775, the public/system permission is 777 as well as all it's inner directory. The tmp directory permission is : 775 too. Moreover the user used to deploy the application is www-data:root

Image file is not recognized by the 'identify' command. (heroku)

依然范特西╮ 提交于 2019-12-09 09:44:54
问题 I'm trying to have Paperclip working with Heroku and Amazon S3. Everything works fine on localhost (mac OS and Amazon), but when I'm deploying to heroku and trying the feature, I have this error : 2 errors prohibited this area from being saved: Asset /tmp/paris20121005-2-2cwxgx.jpg is not recognized by the 'identify' command. Asset /tmp/paris20121005-2-2cwxgx.jpg is not recognized by the 'identify' command. It works when I remove the :styles => { } option in my model, but the file isn't

Using Paperclip within seeds.rb

会有一股神秘感。 提交于 2019-12-09 08:07:12
问题 Let's says I have the following entry in my seeds.rb file : Image.create(:id => 52, :asset_file_name => "somefile.jpg", :asset_file_size => 101668, :asset_content_type => "image/jpeg", :product_id => 52) If I seed it, it tries to process the image specified, I get this error : No such file or directory - {file path} etc... My images are backed up, so I don't really need to create them; but I need the record though. I can't comment the paperclip directive in my model; then it works; but I

paperclip callbacks or simple processor?

淺唱寂寞╮ 提交于 2019-12-09 07:53:57
问题 I wanted to run the callback after_post_process but it doesn't seem to work in Rails 3.0.1 using Paperclip 2.3.8. It gives an error: undefined method `_post_process_callbacks' for #<Class:0x102d55ea0> I want to call the Panda API after the file has been uploaded. I would have created my own processor for this, but as Panda handles the processing, and it can upload the files as well, and queue itself for an undetermined duration I thought a callback would do fine. But the callbacks don't seem