Created
October 4, 2009 07:14
-
-
Save yewreeka/201224 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 [email protected]? @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