Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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)
Add Comment
Please, Sign In to add comment