On Sep 11, 1:29 am, Keith Raymond <li...@ruby-forum.com> wrote:
> Hello all,
>
> I'm quite baffled/agitated by this.  I'm using paperclip to allow upload
> of images to my application.  This is working fine, it's saving the the
> images exactly where its supposed to and it's saving the image objects
> as its supposed to.
>
> The problem is that I can't display these images in the browser.  I've
> had this issue in a couple other applications I've made and just got
> around it by having paperclip save to the public folder and pull from
> there to display the desired image.  But I feel as though I should get
> this sorted out.
>
> So here goes:
>
> My image model (paperclip)
> ---------------------------------
> class Image < ActiveRecord::Base
>   class ContentType
>     IMAGES = ["image/png", "image/x-png", "image/jpg", "image/jpeg",
>               "image/pjpeg", "image/gif", "image/bmp", "image/tiff"]
>     GIF = ["image/gif"]
>
>     def self.allowed_types
>       IMAGES + GIF
>     end
>   end
>
>   belongs_to :attachable, :polymorphic => true
>   has_attached_file :attachment,
>     :path          =>
> ":rails_root/uploaded/:attachable_type/:attachable_id/:id_:style.:extension ",
>     :url           => "/images/:id_:style.:extension",

>
> When I print out the image.url and the image.path I get:
> /images/2_preview.png?1315164150
> /Users/<username>/Sites/myapp/uploaded/avatars/1/2_preview.png
>
> Any help here would be greatly appreciated.  I'm at a loss as to how
> this is not working.

Unless you've got an ImagesController (not shown here), the :url
argument you're using is the problem. Files in the public directory
are served as-is, so yours will be in /
uploaded/:attachable_type/:attachable_id/:id_:style.:extension

--Matt Jones

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to