daily pastebin goal
63%
SHARE
TWEET

Untitled

a guest Mar 13th, 2018 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. get '/rugs/?' do
  2.   @images = Image.all
  3.   haml(:home)
  4. end
  5.  
  6. get '/rugs/:id' do
  7.   @image = Image.get(params[:id])
  8.   haml :show
  9. end
  10. -----------------------
  11. #inside of 'lib/models'
  12. require 'datamapper'
  13.  
  14. DataMapper::setup(:default, ENV['DATABASE_URL'] || 'mysql://root@localhost/ugly_rugs')
  15.  
  16. class Image
  17.   include DataMapper::Resource
  18.  
  19.   property :id,          Serial
  20.   property :path,        String
  21.   property :created_at,  DateTime
  22. end
  23.  
  24. --------------------------
  25. #inside of home.haml
  26. -#images need to have a loop to show all existing ones
  27. !!! strict
  28. %h1.header HI!
  29. %table
  30.   -if !@images.nil? @images.each do |i|
  31.     %tr %img{:src => "#{i.path}"}
  32.        
  33.  
  34. =haml(:navigation, :layout => false)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top