Skip to content

Instantly share code, notes, and snippets.

@jarodl
Created October 4, 2009 07:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jarodl/201224 to your computer and use it in GitHub Desktop.
Save jarodl/201224 to your computer and use it in GitHub Desktop.
get '/rugs/?' do
@images = Image.all
haml(:home)
end
get '/rugs/:id' do
@image = Image.get(params[:id])
haml :show
end
-----------------------
#inside of 'lib/models'
require 'datamapper'
DataMapper::setup(:default, ENV['DATABASE_URL'] || 'mysql://root@localhost/ugly_rugs')
class Image
include DataMapper::Resource
property :id, Serial
property :path, String
property :created_at, DateTime
end
--------------------------
#inside of home.haml
-#images need to have a loop to show all existing ones
!!! strict
%h1.header HI!
%table
-if !@images.nil? @images.each do |i|
%tr %img{:src => "#{i.path}"}
=haml(:navigation, :layout => false)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment