paperclip

Paperclip Error: uninitialized constant Paperclip (NameError)

依然范特西╮ 提交于 2019-12-22 08:17:47
问题 Trying to install paperclip (the cloudfiles fork), but getting an error: config/enviroments/development.rb:28:in 'block in <top (required)>': uninitialized constant Paperclip (NameError) This is how I installed everything. gemfile: gem 'cloudfiles', '>=1.4.9' gem 'paperclip-cloudfiles', '~>2.3' config/environment.rb config.gem 'paperclip-cloudfiles', :lib => 'paperclip' config/enviroments/development.rb Paperclip.options[:command_path] = "/ImageMagick/6.6.9-Q16/" #ImageMagick is at c:

How to upload file via the JSON interface in Rails

本小妞迷上赌 提交于 2019-12-22 08:17:47
问题 I have a web service in Rails which among all else should provide file upload functionality to the clients. The clients all use JSON to talk to the webservice. I use the Paperclip plugin for upload management. The problem is I do not know how to upload a file via JSON. All works in the web formular, but I cannot find information on how to consctruct my JSON Request to send files to the server. Can somebody help out? Regards, Angel Kafazov 回答1: You don't need to use Paperclip for uploading

Overriding content_type for Rails Paperclip plugin

匆匆过客 提交于 2019-12-22 05:40:10
问题 I think I have a bit of a chicken and egg problem. I would like to set the content_type of a file uploaded via Paperclip. The problem is that the default content_type is only based on extension, but I'd like to base it on another module. I seem to be able to set the content_type with the before_post_process class Upload < ActiveRecord::Base has_attached_file :upload before_post_process :foo def foo logger.debug "Changing content_type" #This works self.upload.instance_write(:content_type,

where from does paperclip get the name of original file?

核能气质少年 提交于 2019-12-22 03:50:24
问题 i started using nginx upload module (which creates upload files like /tmp/000121545) but i need paperclip to use original filename while saving files (like /public/avatars/LuckyLuke.jpg) previously in the parameters Rails were passing just "avatar"=>#<File:/tmp/RackMultipart20100413-6151-t3ecq0-0> no original filename as well, so i am wondering where from does it come in paperclip? i tried looking through plugin code but it's currently a bit too complex for me. 回答1: The browser sends a http

where from does paperclip get the name of original file?

烂漫一生 提交于 2019-12-22 03:50:08
问题 i started using nginx upload module (which creates upload files like /tmp/000121545) but i need paperclip to use original filename while saving files (like /public/avatars/LuckyLuke.jpg) previously in the parameters Rails were passing just "avatar"=>#<File:/tmp/RackMultipart20100413-6151-t3ecq0-0> no original filename as well, so i am wondering where from does it come in paperclip? i tried looking through plugin code but it's currently a bit too complex for me. 回答1: The browser sends a http

Rails, Getting a File's name when uploading a file to the server

旧时模样 提交于 2019-12-22 02:03:43
问题 I'm using an AJAX uploader in Rails 3, along with paper_clip and have files uploading here: def upload @photo = Photo.create({ :photo => params[:file], :title => params[:filename] }) respond_to do |format| format.json end end I want to set the photo's title as the photo's filename, but don't know how to, even though params[:file] does have the file and is being uploaded to S3. Any ideas? Thanks 回答1: params[:file].original_filename has the filename you are looking for. 回答2: params[:name]

Undefined method “has_attached_file” for my ActiveRecord model

瘦欲@ 提交于 2019-12-22 01:01:40
问题 I followed the docs at https://github.com/thoughtbot/paperclip exactly to install implement paperclip in my app for image uploading. I am currently using gem 'paperclip', '~> 5.0.0.beta1'. After I did the migration, the four columns were added onto my schema properly: t.string "picture_file_name" t.string "picture_content_type" t.integer "picture_file_size" t.datetime "picture_updated_at" My paperclip should therefore be installed correctly. However, when I proceeded to add the following two

`fetch': key not found: “S3_BUCKET_NAME” (KeyError) with paperclip/aws s3/rails

*爱你&永不变心* 提交于 2019-12-21 20:58:53
问题 I am getting a 'fetch': key not found: "S3_BUCKET_NAME" (KeyError) error in rails (4.2.3) using 'aws-sdk', '~> 2.3' and "paperclip", "~> 5.0.0" I have set the Keys in my environment via terminal and running heroku config shows them listed. In both my config/environments/development.rb as well as in my config production.rb I have included: config.paperclip_defaults = { storage: :s3, s3_credentials: { bucket: ENV.fetch('S3_BUCKET_NAME'), access_key_id: ENV.fetch('AWS_ACCESS_KEY_ID'), secret

rails paperclip no direct access through sql query from another model

风流意气都作罢 提交于 2019-12-21 20:44:00
问题 if tried to access paperclip images from another model to show in its view through a sql query, it wont show the images. i tried something like this from a category controller wch takes in params from a form, in the index page, thru select box. category controller def show @category = Category.find_by_sql ["select distinct l.* from listings l , categories c, categories_listings cl where c.id = cl.category_id and l.id = cl.listing_id and c.id in (?,?)" , params[:c][:id1] , params[:c][:id2]]

Serving images from public folder when using asset pipeline Rails 3.2

≡放荡痞女 提交于 2019-12-21 20:43:33
问题 I am using Rails 3.2 asset pipeline to serve my assets(images, javascript. css). I have added paperclip for photo uploads. paperclip by default stores files in public/system When I use the url generated by paperclip which is something like /system/users/avatar/000/000/thumb/whatever.jpg It gives me no route error. the file is there at the above location but I think it may be issue with asset pipleline. Any ideas what might be going wrong ? 回答1: just like user451893 said. you should configure