Search Results

Search found 152 results on 7 pages for 'paperclip'.

Page 2/7 | < Previous Page | 1 2 3 4 5 6 7  | Next Page >

  • Rails Beta3 & PaperClip & Passenger Bundler::PathError

    - by firecall
    So I'm going around in circles with this - I'm using a fork of the Paperclip Rails gem to get it to work with Rails3. Works fine on my OSX box with Passenger. But on my server (CentOS 5) I get this this error: git://github.com/lmumar/paperclip.git (at rails3) is not checked out. Please runbundle install(Bundler::PathError)Blockquote I tried Bundle Pack, but that doesnt pack gems from github. I read a post about setting the parh to the BUNDLE_HOME in my application.rb file which I tried: ENV['BUNDLER_HOME']="~/.bundle/ruby/1.8/bundler/gems/" But that doesnt work. Any ideas anyone? I dont know what else to do and have no idea how to debug or trace the problem further :( Passenger version 2.2.11. thanks.

    Read the article

  • Paperclip generating wrong URLs in Heroku

    - by Tony
    Paperclip is generating wrong URLs in Heroku. I have an Audio model which has a mp3 field as follows: class Audio < ActiveRecord::Base has_attached_file :mp3, :storage => :s3, :s3_credentials => S3_CREDENTIALS, :bucket => S3_CREDENTIALS[:bucket], :path => ":rails_root/public/system/:attachment/:id/:style/:filename", :url => "/system/:attachment/:id/:style/:filename" I am calling audio.mp3.url from a controller, and it returns http://s3.amazonaws.com/MyApp/audios/mp3s//original/96a9ae89302fdf8462ee05eb829f2e17578b144e20120908-2-11f61zr.mp3?1347135050 instead of http://s3.amazonaws.com/MyApp/audios/mp3s/000/000/004/original/96a9ae89302fdf8462ee05eb829f2e17578b144e20120908-2-11f61zr.mp3?1347135050 (which works) Why is it missing the '000/000/004' part of the route? The same model is generating the right URL when used in a view. Any help? I am using paperclip 3.2.0 and Rails 3.1.8. Any help?

    Read the article

  • Uploading images from Flex to Rails using Paperclip

    - by 23tux
    Hi everyone, I'm looking for a way to upload images that were created in my flex app to rails. I've tried to use paperclip, but it don't seem to work. I've got this tutorial here: http://blog.alexonrails.net/?p=218 The problem is, that they are using a FileReference to browse for files on the clients computer. They call the .upload(...) function and send the data to the upload controller. But I'm using a URLLoader to upload a image, that is modified in my Flex-App. First, here is the code from the tutorial: private function selectHandler(event:Event):void { var vars:URLVariables = new URLVariables(); var request:URLRequest = new URLRequest(uri); request.method = URLRequestMethod.POST; vars.description = "My Description"; request.data = vars; var uploadDataFieldName:String = 'filemanager[file]'; fileReference.upload(request, uploadDataFieldName); } I don't know how to set that var uploadDataFieldName:String = 'filemanager[file]'; in a URLLoader. I've got the image data compressed as a JPEG in a ByteArray. It looks like this: public function savePicture():void { var filename:String = "blubblub.jpg"; var vars:URLVariables = new URLVariables(); vars.position = layoutView.currentPicPosition; vars.url = filename; vars.user_id = 1; vars.comic_id = 1; vars.file_content_type = "image/jpeg"; vars.file_file_name = filename; var rawBytes:ByteArray = new JPGEncoder(75).encode(bitmapdata); vars.picture = rawBytes; var request:URLRequest = new URLRequest(Data.SERVER_ADDR + "pictures/upload"); request.method = URLRequestMethod.POST; request.data = vars; var loader:URLLoader = new URLLoader(request); loader.addEventListener(Event.COMPLETE, savePictureHandler); loader.addEventListener(IOErrorEvent.IO_ERROR, errorHandlerUpload); loader.load(request); } If I set the var.picture URLVariable to the bytearray, then I get the error, that the upload is nil. Here is the Rails part: Picture-Model: require 'paperclip' class Picture < ActiveRecord::Base # relations from picture belongs_to :comic belongs_to :user has_many :picture_bubbles has_many :bubbles, :through => :picture_bubbles # attached file for picture upload -> with paperclip plugin has_attached_file :file, :path => "public/system/pictures/:basename.:extension" end and the picture controller with the upload function: class PicturesController < ApplicationController protect_from_forgery :except => :upload def upload @picture = Picture.new(params[:picture]) @picture.position = params[:position] @picture.comic_id = params[:comic_id] @picture.url = params[:url] @picture.user_id = params[:user_id] if @picture.save render(:nothing => true, :status => 200) else render(:nothing => true, :status => 500) end end end Does anyone know how to solve this problem? thx, tux

    Read the article

  • Paperclip: "missing" image when uses has_one

    - by EricR
    I'm working on a website that allows people who run bed and breakfast businesses to post their accommodations. I would like to require that they include a "profile image" of the accommodation when they post it, but I also want to give them the option to add more images later (this will be developed after). I thought the best thing to do would be to use the Paperclip gem and have a Accommodation and a Photo in my application, the later belonging to the first as an association. A new Photo record is created when they create an Accommodation. It has both id and accommodation_id attributes. However, the image is never uploaded and none of the Paperclip attributes get set (image_file_name: nil, image_content_type: nil, image_file_size: nil), so I get Paperclip's "missing" photo. Any ideas on this one? It's been keeping me stuck for a few days now. Accommodation models/accommodation.rb class Accommodation < ActiveRecord::Base validates_presence_of :title, :description, :photo, :thing, :location attr_accessible :title, :description, :thing, :borough, :location, :spaces, :price has_one :photo end controllers/accommodation_controller.erb class AccommodationsController < ApplicationController before_filter :login_required, :only => {:new, :edit} uses_tiny_mce ( :options => { :theme => 'advanced', :theme_advanced_toolbar_location => 'top', :theme_advanced_toolbar_align => 'left', :theme_advanced_buttons1 => 'bold,italic,underline,bullist,numlist,separator,undo,redo', :theme_advanced_buttons2 => '', :theme_advanced_buttons3 => '' }) def index @accommodations = Accommodation.all end def show @accommodation = Accommodation.find(params[:id]) end def new @accommodation = Accommodation.new end def create @accommodation = Accommodation.new(params[:accommodation]) @accommodation.photo = Photo.new(params[:photo]) @accommodation.user_id = current_user.id if @accommodation.save flash[:notice] = "Successfully created your accommodation." render :action => 'show' else render :action => 'new' end end def edit @accommodation = Accommodation.find(params[:id]) end def update @accommodation = Accommodation.find(params[:id]) if @accommodation.update_attributes(params[:accommodation]) flash[:notice] = "Successfully updated accommodation." render :action => 'show' else render :action => 'edit' end end def destroy @accommodation = Accommodation.find(params[:id]) @accommodation.destroy flash[:notice] = "Successfully destroyed accommodation." redirect_to :inkeep end private def check_owner end end views/accommodations/_form.html.erb <%= form_for @accommodation, :html => {:multipart => true} do |f| %> <%= f.error_messages %> <p> Title<br /> <%= f.text_field :title, :size => 60 %> </p> <p> Description<br /> <%= f.text_area :description, :rows => 17, :cols => 75, :class => "mceEditor" %> </p> <p> Photo<br /> <%= f.file_field :photo %> </p> [... snip ...] <p><%= f.submit %></p> <% end %> Photo The controller and views are still the same as when Rails generated them. models/photo.erb class Photo < ActiveRecord::Base attr_accessible :image_file_name, :image_content_type, :image_file_size belongs_to :accommodation has_attached_file :image, :styles => { :thumb=> "100x100#", :small => "150x150>" } end

    Read the article

  • What is wrong with Paperclip+ImageMagick on Heroku?

    - by Yuri
    UPD class User < ActiveRecord::Base Paperclip.options[:swallow_stderr] = false has_attached_file :photo, :styles => { :square => "100%", :large => "100%" }, :convert_options => { :square => "-auto-orient -geometry 70X70#", :large => "-auto-orient -geometry X300" }, :storage => :s3, :s3_credentials => "#{RAILS_ROOT}/config/s3.yml", :path => ":attachment/:id/:style.:extension", :bucket => 'mybucket' validates_attachment_size :photo, :less_than => 5.megabyte end Works great on local machine, but gives me an error on Heroku: There was an error processing the thumbnail for stream.20143 The thing is I want to auto-orient photos before resizing, so they resized properly. The only working variant now(thanks to jonnii) is resizing without auto-orient: ... as_attached_file :photo, :styles => { :square => "70X70#", :large => "X300" }, :storage => :s3, :s3_credentials => "#{RAILS_ROOT}/config/s3.yml", :path => ":attachment/:id/:style.:extension", :bucket => 'mybucket' ... How to pass additional convert options to paperclip on Heroku?

    Read the article

  • Paperclip and xhr.sendAsBinary

    - by Denis
    Hi, I use paperclip to add a file to my model. I want to use the new feature of firefox 3.6, xhr.sendAsBinary, to send a file with an ajax request. Here is how I build my request : var xhr = new XMLHttpRequest(); xhr.open("POST", "/photos?authenticity_token=" + token + "&photo[name]=" + img.name + "&photo[size]=" + img.size); xhr.overrideMimeType('text/plain; charset=x-user-defined-binary'); xhr.sendAsBinary(bin); name and size are saved in my model without problem but the file itself is not catched by paperclip. my model class Photo < ActiveRecord::Base has_attached_file :photo, :styles => { :medium => "300x300>", :thumb => "100x100>" } end the migration def self.up add_column :photos, :photo_file_name, :string add_column :photos, :photo_content_type, :string add_column :photos, :photo_file_size, :integer add_column :photos, :photo_updated_at, :datetime end and my controller # POST /photos # POST /photos.xml def create @photo = Photo.new(params[:photo]) respond_to do |format| if @photo.save format.html { redirect_to(@photo, :notice => 'Photo was successfully created.') } format.xml { render :xml => @photo, :status => :created, :location => @photo } else format.html { render :action => "new" } format.xml { render :xml => @photo.errors, :status => :unprocessable_entity } end end end Any idea how to solve this issue? Thanks

    Read the article

  • Paperclip and Amazon S3 Issue

    - by Jimmy
    Hey everyone, I have a rails app running on Heroku. I am using paperclip for some simple image uploads for user avatars and some other things, I have S3 set as my backend and everything seems to be working fine except when trying to push to S3 I get the following error: The AWS Access Key Id you provided does not exist in our records. Thinking I mis-pasted my access key and secret key, I tried again, still no luck. Thinking maybe it was just a buggy key I deactivated it and generated a new one. Still no luck. Now for both keys I have used the S3 browser app on OS X and have been able to connect to each and view my current buckets and add/delete buckets. Is there something I should be looking out for? I have my application's S3 and paperclip setup like so development: bucket: (unique name) access_key_id: ENV['S3_KEY'] secret_access_key: ENV['S3_SECRET'] test: bucket: (unique name) access_key_id: ENV['S3_KEY'] secret_access_key: ENV['S3_SECRET'] production: bucket: (unique_name) access_key_id: ENV['S3_KEY'] secret_access_key: ENV['S3_SECRET'] has_attached_file :cover, :styles => { :thumb => "50x50" }, :storage => :s3, :s3_credentials => "#{RAILS_ROOT}/config/s3.yml", :path => ":class/:id/:style/:filename" Note: I just added the (unique name) bits, those aren't actually there--I have also verified bucket names, but I don't even think this is getting that far. I also have my heroku environment vars setup correctly and have them setup on dev

    Read the article

  • using paperclip with secure and non-secure files

    - by crankharder
    First off, we have this namespaced/sti'd structure for our different types of 'Media' Media< Ar::Base Media::Local < Media Media::Local::Image < Media::Local Media::Local::Csv < Media::Local etc... etc.. This is excellent since a user can have many media, and how we display each piece of media is based on the class name and a co-responding partial. But what if we have some Csv's that need to be secure? That is, they can't reside inside of public. I really hate the idea of branching Media again and doing something like this: Media::Secure < Media Media::Secure::Image < Media::Secure Media::NotSecure < Media Media::NotSecure::Image < Media::NotSecure ...where Secure and NotSecure would have different params passed to has_attached_file. Now there are two classes that represent Image and it makes my view/helper system that much more complicated -- not to mention it feels very obtuse. What I would really like to do is be able to change where certain Paperclip::Attachment objects get saved before they get saved (e.g. anything uploaded through foo_secure_action) -- but I can't seem to make this work. Paperclip::Attachment has an @options hash with :path and :url, but changing those before it is saved doesn't have an effect on where it actually gets set. Even if this is possible, I'm not sure if it would have further consequences... I'm open to alternative ideas for structuring this data, but for the moment I like the idea of using STI for this situation.

    Read the article

  • PDF to PNG Processor - Paperclip

    - by Josh Crowder
    I am trying to develop a system in which a user can upload a slideshow (pdf) and it'll export each slide as a png. After some digging around I came across a post on here that suggested using a processor. I've had a go, but I cant get the command to run, if it is running then I don't know what is happening because no errors are being shown. Any help would be appreciated! module Paperclip class Slides < Processor def initialize(file, options = {}, attachment = nill) super @file = file @instance = options[:instance] @current_format = File.extname(@file.path) @basename = File.basename(@file.path, @current_format) end def make dst = Tempfile.new( [ @basename, @format].compact.join(".")) dst.binmode command = <<-end_command -size 640x300 #{ File.expand_path(dst.path) } tester.png end_command begin success = Paperclip.run("convert", command.gsub(/\s+/, " "))) rescue PaperclipCommandLineError raise PaperclipError, "There was an error processing the thumbnail for #{@basename}" end end end end I think my problem is with the convert command... When I run that command by hand, it works but it doesn't give the details of each slide it just executes it. What I need to happen is once its made all the slides, pass back the data to a new model... or I know where all the slides are, but once I get to that point I'm not sure what todo.

    Read the article

  • Overriding content_type for Rails Paperclip plugin

    - by Fotios
    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,"foobar") # This fails because the file does not actually exist yet self.upload.instance_write(:content_type,file_type(self.upload.path) end # Returns the filetype based on file command (assume it works) def file_type(path) return `file -ib '#{path}'`.split(/;/)[0] end end But...I cannot base the content type on the file because Paperclip doesn't write the file until after_create. And I cannot seem to set the content_type after it has been saved or with the after_create callback (even back in the controller) So I would like to know if I can somehow get access to the actual file object (assume there are no processors doing anything to the original file) before it is saved, so that I can run the file_type command on that. Or is there a way to modify the content_type after the objects have been created.

    Read the article

  • Paperclip: Stay put on edit

    - by EricR
    When a user edits something in my application, they're forced to re-upload their image via paperclip even if they aren't changing it. Failing to do so will cause an error, since I validate_presence_of :image. This is quite annoying. How can I make it so Paperclip won't update its attributes if a user simply doesn't supply a new image on an edit? The photo controller is fresh out of Rails' scaffold generator. The rest of the source code is provided below. models/accommodation.rb class Accommodation < ActiveRecord::Base attr_accessible :photo validates_presence_of :photo has_one :photo has_many :notifications belongs_to :user accepts_nested_attributes_for :photo, :allow_destroy => true end controllers/accommodation_controller.rb class AccommodationsController < ApplicationController def index @accommodations = Accommodation.all end def show @accommodation = Accommodation.find(params[:id]) rescue ActiveRecord::RecordNotFound flash[:error] = "Accommodation not found." redirect_to :home end def new @accommodation = current_user.accommodations.build @accommodation.build_photo end def create @accommodation = current_user.accommodations.build(params[:accommodation]) if @accommodation.save flash[:notice] = "Successfully created your accommodation." redirect_to @accommodation else @accommodation.build_photo render :new end end def edit @accommodation = Accommodation.find(params[:id]) @accommodation.build_photo rescue ActiveRecord::RecordNotFound flash[:error] = "Accommodation not found." redirect_to :home end def update @accommodation = Accommodation.find(params[:id]) if @accommodation.update_attributes(params[:accommodation]) flash[:notice] = "Successfully updated accommodation." redirect_to @accommodation else @accommodation.build_photo render :edit end end def destroy @accommodation = Accommodation.find(params[:id]) @accommodation.destroy flash[:notice] = "Successfully destroyed accommodation." redirect_to :inkeep end end models/photo.rb class Photo < ActiveRecord::Base attr_accessible :image, :primary belongs_to :accommodation has_attached_file :image, :styles => { :thumb=> "100x100#", :small => "150x150>" } end

    Read the article

  • Paperclip validates_attachment_content_type for mp3 triggered when attaching mp3

    - by zoltarSpeaks
    Hey everyone, Struggling to workout when i add the following validtion to my Voice model using paperclip, it is being triggered when i try and upload an mp3: class Voice < ActiveRecord::Base has_attached_file :clip validates_attachment_presence :clip validates_attachment_content_type :clip, :content_type => [ 'application/mp3', 'application/x-mp3', 'audio/mpeg', 'audio/mp3' ], :message => 'file must be of filetype .mp3' validates_attachment_size :clip, :less_than => 10.megabytes validates_presence_of :title end I have tried a number of different mp3 files but none of them seem to upload because the validation is failing.

    Read the article

  • Simple cropping with Paperclip

    - by collimarco
    I would like to crop images on upload using Paperclip to get square thumbs from the center of the original picture. I find out a method in documentation that seems to do exactly what I want: transformation_to(dst, crop = false) The problem is that I can't figure out where to use this method. It would be great to simply pass something as a parameter here: has_attached_file :picture, :styles = { :medium = "600x600", :thumb = "something here" }

    Read the article

  • Problems installing RMagick with Paperclip in Rails 3

    - by Smickie
    Hi, I'm trying to use paperclip in rails and when I'm doing the "bundle install" I'm getting the following error: Can't install RMagick 2.13.1. Can't find Magick-config in /usr/local/mysql/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/X11/bin:/Users/seanhinton/.rvm/bin What I'm wondering is how do I install RMagick (is that what I need?) on my machine (it's OSX 10.6)? Cheers!

    Read the article

  • Stop output of image if no record - paperclip - Ruby on rails

    - by bgadoci
    I have just installed paperclip into my ruby on rails blog application. Everything is working great...too great. I am trying to figure out how to tell paperclip not to output anything if there is no record in the table so that I don't have broken image links everywhere. How, and where, do I do this? Here is my code: class Post < ActiveRecord::Base has_attached_file :photo, :styles => { :small => "150x150"} validates_presence_of :body, :title has_many :comments, :dependent => :destroy has_many :tags, :dependent => :destroy has_many :ugtags, :dependent => :destroy has_many :votes, :dependent => :destroy belongs_to :user after_create :self_vote def self_vote # I am assuming you have a user_id field in `posts` and `votes` table. self.votes.create(:user => self.user) end cattr_reader :per_page @@per_page = 10 end View <% div_for post do %> <div id="post-wrapper"> <div id="post-photo"> <%= image_tag post.photo.url(:small) %> </div> <h2><%= link_to_unless_current h(post.title), post %></h2> <div class="light-color"> <i>Posted <%= time_ago_in_words(post.created_at) %></i> ago </div> <%= simple_format truncate(post.body, :length => 600) %> <div id="post-options"> <%= link_to "Read More >>", post %> | <%= link_to "Comments (#{post.comments.count})", post %> | <%= link_to "Strings (#{post.tags.count})", post %> | <%= link_to "Contributions (#{post.ugtags.count})", post %> | <%= link_to "Likes (#{post.votes.count})", post %> </div> </div> <% end %>

    Read the article

  • Paperclip Progres bar

    - by Josh Crowder
    I havve been looking around for something that shows the progress of an upload using Paperclip. I can't find any solutions is there any out there? If not is there any particular progress uploader that can be recommended?

    Read the article

  • Image_tag .blank? - paperclip - Ruby on rails

    - by bgadoci
    I have just installed paperclip into my ruby on rails blog application. Everything is working great...too great. I am trying to figure out how to tell paperclip not to output anything if there is no record in the table so that I don't have broken image links everywhere. How, and where, do I do this? Here is my code: class Post < ActiveRecord::Base has_attached_file :photo, :styles => { :small => "150x150"} validates_presence_of :body, :title has_many :comments, :dependent => :destroy has_many :tags, :dependent => :destroy has_many :ugtags, :dependent => :destroy has_many :votes, :dependent => :destroy belongs_to :user after_create :self_vote def self_vote # I am assuming you have a user_id field in `posts` and `votes` table. self.votes.create(:user => self.user) end cattr_reader :per_page @@per_page = 10 end View <% div_for post do %> <div id="post-wrapper"> <div id="post-photo"> <%= image_tag post.photo.url(:small) %> </div> <h2><%= link_to_unless_current h(post.title), post %></h2> <div class="light-color"> <i>Posted <%= time_ago_in_words(post.created_at) %></i> ago </div> <%= simple_format truncate(post.body, :length => 600) %> <div id="post-options"> <%= link_to "Read More >>", post %> | <%= link_to "Comments (#{post.comments.count})", post %> | <%= link_to "Strings (#{post.tags.count})", post %> | <%= link_to "Contributions (#{post.ugtags.count})", post %> | <%= link_to "Likes (#{post.votes.count})", post %> </div> </div> <% end %>

    Read the article

  • How to copy a file using Paperclip

    - by CalebHC
    Does anyone know of a way to copy files with Paperclip using S3 for storage? Before I try to write my own, I just wanted to make sure there wasn't already a way to do this. Speaking of copying, is there an easier way of copying a whole model including all of its has_many relationships? Sorry for the second question but it kind of fits! :) Thanks

    Read the article

  • paperclip plugin not support for I18n

    - by user354413
    I've added I18n support for error messages: Now you can define translations for the errors messages in e.g. your YAML locale file: en: paperclip: errors: attachment: size: "Invalid file size" content_type: "Unsupported content type" presence: "Cant' be blank" when I use validates_attachemnt_zie :avatar how to get error message?

    Read the article

  • Installing Paperclip - "undefined method `has_attached_file` for" - Ruby on Rails

    - by bgadoci
    I just installed the plugin for Paperclip and I am getting an error message "undefined method has_attached_file for. Not sure why I am getting this. Here is the full error message. NoMethodError (undefined method `has_attached_file' for #<Class:0x10338acd0>): /Users/bgadoci/.gem/ruby/1.8/gems/will_paginate-2.3.12/lib/will_paginate/finder.rb:170:in `method_missing' app/models/post.rb:2 app/controllers/posts_controller.rb:50:in `show' For some reason it is referencing the will_paginate gem. From what I can find, it seems that either there is something wrong w/ my PostsController#index or perhaps a previously attempt at installing the gem instead of the plugin (in which case I have read I should be able to remedy through the /config/environments.rb file somehow). I didn't think that previous gem installation would matter as I did it in an old version of the site that I trashed before installing the plugin. In the current version of the site I show that the Table has been updated with the Paperclip columns after migration. Here is my code: PostsController#index def index @tag_counts = Tag.count(:group => :tag_name, :order => 'count_all DESC', :limit => 20) conditions, joins = {}, :votes @vote_counts = Vote.count(:group => :post_title, :order => 'count_all DESC', :limit => 20) conditions, joins = {}, :votes unless(params[:tag_name] || "").empty? conditions = ["tags.tag_name = ? ", params[:tag_name]] joins = [:tags, :votes] end @posts=Post.paginate( :select => "posts.*, count(*) as vote_total", :joins => joins, :conditions=> conditions, :group => "votes.post_id", :order => "created_at DESC", :page => params[:page], :per_page => 5) @popular_posts=Post.paginate( :select => "posts.*, count(*) as vote_total", :joins => joins, :conditions=> conditions, :group => "votes.post_id", :order => "vote_total DESC", :page => params[:page], :per_page => 3) respond_to do |format| format.html # index.html.erb format.xml { render :xml => @posts } format.json { render :json => @posts } format.atom end end Post Model class Post < ActiveRecord::Base has_attached_file :photo validates_presence_of :body, :title has_many :comments, :dependent => :destroy has_many :tags, :dependent => :destroy has_many :votes, :dependent => :destroy belongs_to :user after_create :self_vote def self_vote # I am assuming you have a user_id field in `posts` and `votes` table. self.votes.create(:user => self.user) end cattr_reader :per_page @@per_page = 10 end /views/posts/new.html.erb <h1>New post</h1> <%= link_to 'Back', posts_path %> <% form_for(@post, :html => { :multipart => true}) do |f| %> <%= f.error_messages %> <p> <%= f.label :title %><br /> <%= f.text_field :title %> </p> <p> <%= f.label :body %><br /> <%= f.text_area :body %> </p> <p> <%= f.file_field :photo %> </p> <p> <%= f.submit 'Create' %> </p> <% end %>

    Read the article

  • How to process images with paperclip on Heroku?

    - by Yuri
    I use Heroku for my app. I want to auto-orient image and then to resize it. So I do: class User < ActiveRecord::Base Paperclip.options[:swallow_stderr] = false has_attached_file :photo, :styles => { :square => "100%", :large => "100%" }, :convert_options => { :square => "-auto-orient -geometry 70X70#", :large => "-auto-orient -geometry X300" }, :storage => :s3, :s3_credentials => "#{RAILS_ROOT}/config/s3.yml", :path => ":attachment/:id/:style.:extension", :bucket => 'mybucket' validates_attachment_size :photo, :less_than => 5.megabyte end It does not work with error: There was an error processing the thumbnail for stream.20143 What am I doing wrong?

    Read the article

  • rails paperclip and passenger `is not recognized by the 'identify' command`

    - by Joseph Silvashy
    When I upload a photo, my model fails validation, err well even without any validations I'm returned this error: /tmp/stream20100103-13830-ywmerx-0 is not recognized by the 'identify' command. and /tmp/stream20100103-13830-ywmerx-0 is not recognized by the 'identify' command. I'm confident this is not related to ImageMagick because I've removed any image processing from the uploading, also I've tried uploading different mime types, like .txt files and the such. Additionally, I found something that may work. A blog post claims that putting the following in my environment (in this case development.rb) Paperclip.options[:command_path] = "/opt/local/bin"

    Read the article

  • Getting Paperclip to work in Rails

    - by Danny McClelland
    Hi Everyone, I have installed the Paperclip plugin to attempt to upload an avatar for my kase model. For some reason, the select the file button shows, and I can choose a file - but then when I click update the kase - it takes me to the show page, but the missing.png rather than the selected image. kase.rb class Kase < ActiveRecord::Base def self.all_latest find(:all, :order => 'created_at DESC', :limit => 5) end def self.search(search, page) paginate :per_page => 5, :page => page, :conditions => ['name like ?', "%#{search}%"], :order => 'name' end # Paperclip has_attached_file :avatar, :styles => { :medium => "300x300>", :thumb => "100x100>" } end kases_controller.rb # GET /kases/new # GET /kases/new.xml def new @kase = Kase.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @kase } end end new.html.erb <% content_for :header do -%> Cases <% end -% <% form_for(@kase) do |f| %> <%= f.error_messages %> <ul id="kases_new"> <li> <%= f.file_field :avatar %></li> <li>Job Ref.<span><%= f.text_field :jobno %></span></li> <li>Case Subject<span><%= f.text_field :casesubject %></span></li> <li>Transport<span><%= f.text_field :transport %></span></li> <li>Goods<span><%= f.text_field :goods %></span></li> <li>Date Instructed<span><%= f.date_select :dateinstructed %></span></li> <li>Case Status<span><%= f.select "kase_status", ['Active', 'On Hold', 'Archived'] %> </span></li> <li>Client Company Name<span><%= f.text_field :clientcompanyname %></span></li> <li>Client Company Address<span><%= f.text_field :clientcompanyaddress %></span></li> <li>Client Company Fax<span><%= f.text_field :clientcompanyfax %></span></li> <li>Case Handler Name<span><%= f.text_field :casehandlername %></span></li> <li>Case Handler Tel<span><%= f.text_field :casehandlertel %></span></li> <li>Case Handler Email<span><%= f.text_field :casehandleremail %></span></li> <li>Claimant Name<span><%= f.text_field :claimantname %></span></li> <li>Claimant Address<span><%= f.text_field :claimantaddress %></span></li> <li>Claimant Contact<span><%= f.text_field :claimantcontact %></span></li> <li>Claimant Tel<span><%= f.text_field :claimanttel %></span></li> <li>Claimant Mob<span><%= f.text_field :claimantmob %></span></li> <li>Claimant Email<span><%= f.text_field :claimantemail %></span></li> <li>Claimant URL<span><%= f.text_field :claimanturl %></span></li> <li>Comments<span><%= f.text_field :comments %></span></li> </ul> <div class="js_option"> <%= link_to_function "Show financial options.", "Element.show('finance_showhide');" %> </div> <div id="finance_showhide" style="display:none"> <ul id="kases_new_finance"> <li>Invoice Number<span><%= f.text_field :invoicenumber %></span></li> <li>Net Amount<span><%= f.text_field :netamount %></span></li> <li>VAT<span><%= f.text_field :vat %></span></li> <li>Gross Amount<span><%= f.text_field :grossamount %></span></li> <li>Date Closed<span><%= f.date_select :dateclosed %></span></li> <li>Date Paid<span><%= f.date_select :datepaid %></span></li> </ul> <div class="js_option"> <%= link_to_function "I'm confused! Hide financial options.", "Element.hide('finance_showhide');" %> </div> </div> <p> <%= f.submit "Create" %> </p> <% end %> <%= link_to 'Back', kases_path %> I have tried putting the <%= f.file_field :avatar % in it's own form on the same page, but that didn't make a difference. Thanks in advanced! Thanks, Danny

    Read the article

  • Ajax, Multiple Attachments and Paperclip question.

    - by dustmoo
    Alright everyone this is a bit of a complicated setup so if I need to clarify the question just let me know. I have a model: class IconSet < ActiveRecord::Base has_many :icon_graphics end This Model has many icongraphics: class IconGraphic < ActiveRecord::Base belongs_to :icon_set has_attached_file :icon has_attached_file :flagged end As you can see, IconGraphic has two attached files, basically two different versions of the icon that I want to load. Now, this setup is working okay if I edit the icongraphic's individually, however, for ease of use, I have all the icon graphics editable under the IconSet. When you edit the icon set the form loads a partial for the icongraphics: <% form_for @icon_set, :html => {:class => 'nice', :multipart => true} do |f| %> <fieldset> <%= f.error_messages %> <p> <%= f.label :name %> <%= f.text_field :name, :class => "text_input" %> </p> <!-- Loaded Partial for icongraphics --> <div id="icon_graphics"> <%= render :partial => 'icon_graphic', :collection => @icon_set.icon_graphics %> </div> <div class="add_link"> <%= link_to_function "Add an Icon" do |page| page.insert_html :bottom, :icon_graphics, :partial => 'icon_graphic', :object => IconGraphic.new end %> </div> <p><%= f.submit "Submit" %></p> </fieldset> <% end %> This is based largely off of Ryan's Complex Forms Railscast. The partial loads the file_field forms: <div class="icon_graphic"> <% fields_for "icon_set[icon_graphic_attributes][]", icon_graphic do |icon_form|-%> <%- if icon_graphic.new_record? -%> <strong>Upload Icon: </strong><%= icon_form.file_field :icon, :index => nil %><br/> <strong>Upload Flagged Icon: </strong><%= icon_form.file_field :flagged, :index => nil %> <%= link_to_function image_tag('remove_16.png'), "this.up('.icon_graphic').remove()"%><br/> <% else -%> <%= image_tag icon_graphic.icon.url %><br/> <strong>Replace <%= icon_graphic.icon_file_name %>: </strong><%= icon_form.file_field :icon, :index => nil %><br /> <% if icon_graphic.flagged_file_name.blank? -%> <strong>Upload Flagged Icon: </strong><%= icon_form.file_field :flagged, :index => nil %> <% else -%> <strong>Replace <%= icon_graphic.flagged_file_name %>: </strong><%= icon_form.file_field :flagged, :index => nil %> <%= icon_form.hidden_field :flagged, :index => nil %> <% end -%> <%= link_to_function image_tag('remove_16.png'), "mark_for_destroy(this, '.icon_graphic')"%><br/> <%= icon_form.hidden_field :id, :index => nil %> <%= icon_form.hidden_field :icon, :index => nil %> <%= icon_form.hidden_field :should_destroy, :index => nil, :class => 'should_destroy' %> <br/><br/> <%- end -%> <% end -%> </div> Now, this is looking fine when I add new icons, and fill both fields. However, if I edit the IconSet after the fact, and perhaps try to replace the icon with a new one, or if I uploaded only one of the set and try to add the second attachment, paperclip doesn't put the attachments with the right IconGraphic Model. It seems that even though I have the IconGraphic ID in each partial, <%= icon_form.hidden_field :id, :index => nil %> it seems that paperclip either creates a new IconGraphic or attaches it to the wrong one. This all happens when you save the IconSet, which is setup to save the IconGraphic attributes. I know this is complicated.. I may just have to go to editing each icon individually, but if anyone can help, I would appreciate it.

    Read the article

< Previous Page | 1 2 3 4 5 6 7  | Next Page >