Paperclip and viewing images

I have two objects Task and Asset and I want to view image in show task.

Here is my to models

Task.rb

has_many Assets :as => :attachable

And

Asset.rb

has_attached_file :photo, :styles => { :large => “371251>", :small =>
"72
72>”},
:url => “/assets/:id/”,
:path =>
“:rails_root/public/assets/:id/:style.:extension”

belongs_to :attachable, :polymorphic => true

I have the multiple images upload working but when i try to view them in
show.erb.html code below

<% @photo = Asset.find_by_attachable_id(@task.id)%>

<%if !@photo.blank? %>

<%= image_tag (@photo.photo.url(:small) )%>

i’m getting html out put of <img src="/assets/4/?1266410329"
alt"?1266410329">

it should be <img src="/assets/4/small.jpg" alt"small.jpg">

Any help would be grateful

Was simple fix in the end.

Had not specified what naming convention i was trying to call back

I needed to add :style_:basname.:extension to my model code

:url => “/assets/:id/:style_:basename.:extension”,

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs