Displaying an image

33 views
Skip to first unread message

Lawrence Smith

unread,
May 5, 2012, 1:54:35 PM5/5/12
to rubyonra...@googlegroups.com
I am trying to display an image that is in my public/image folder and I
don't know how to.

What I want to do is to be able to assign a photo to an artist so you
can navigate through different artist's photo.

This is my image model

class Image < ActiveRecord::Base
has_many :publishings
has_many :artists, :through => :publishings
has_many :comments,:through => :friends

has_many :comments, :as => :resource, :class_name => "Commentable"
end

This is my image show.html

<p id="notice"><%= notice %></p>

<p>
<b>Title:</b>
<%= @image.title %>
</p>

<p>
<b>Filename:</b>
<%= @image.filename %>
</p>

<p>
<b>Likes:</b>
<%= @image.likes %>
</p>


<%= link_to 'Edit', edit_image_path(@image) %> |
<%= link_to 'Back', images_path %>

Thanks in advance

--
Posted via http://www.ruby-forum.com/.

Colin Law

unread,
May 5, 2012, 4:24:35 PM5/5/12
to rubyonra...@googlegroups.com
On 5 May 2012 18:54, Lawrence Smith <li...@ruby-forum.com> wrote:
> I am trying to display an image that is in my public/image folder and I
> don't know how to.
>
> What I want to do is to be able to assign a photo to an artist so you
> can navigate through different artist's photo.
>
> This is my image model
>
> class Image < ActiveRecord::Base
>  has_many :publishings
>  has_many :artists, :through => :publishings
>  has_many :comments,:through => :friends
>
>  has_many :comments, :as => :resource, :class_name => "Commentable"

You have has_many :comments twice.
For showing the image have a look at image_tag

Colin
Reply all
Reply to author
Forward
0 new messages