Selecting images from db according to type

Ok so this seems easy huh? So I have some images in a db. Some are
marked as “screenshots” and others as “wallpapers”. Now in various parts
of the site, I want to show only “screenshots” and in another area, only
“wallpapers”. In the db, it’s in the column marked “image_type” Here is
what I thought:

The view:

<% for screenshot in @game.images %>
<% end %>


<% for wallpaper in @game.images %>
<% end %>

The Models:

now I have “belongs_to :games” and “has_many :images”

The Controller:

@game = Game.find(params[:id])
@images = Image.find(:all)
@screenshot = Image.find(:all, :conditions => “image_type =
@wallpaper = Image.find(:all, :conditions => “image_type =

now how do I do it, so that it selects only the images I want? Because
instead of selecting the image I want, it selects ALL the images for
both. Please help people, I’m so lost… I think the answer is
really easy, but I’m still learning rails, so be kind :stuck_out_tongue:

  • Jake

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