Created
          February 1, 2013 02:26 
        
      - 
      
- 
        Save esparkman/4688692 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
    
  
  
    
  | %h1 | |
| = @song.title | |
| %p | |
| Release Date: #{@song.released_on.strftime("%e %B %Y") if @song.released_on} | |
| %p | |
| Length: #{@song.length/60} minutes #{@song.length%60} seconds | |
| %pre | |
| = @song.lyrics | |
| %p | |
| %a{href: "/songs"} Back to Songs Index | |
| %p | |
| %a{href: "/songs/#{@song.id}/edit"} Edit this Song | |
| %form{action: "/songs/#{@song.id}", method: "POST"} | |
| %input{type: "hidden", name: "_method", value: "DELETE"} | |
| %input{type: "submit", value: "Delete This Song"} | 
  
    
      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
    
  
  
    
  | require 'dm-core' | |
| require 'dm-migrations' | |
| DataMapper.setup(:default, "postgres://localhost/songsbysinatra") | |
| DataMapper.finalize.auto_upgrade! | |
| class Song | |
| include DataMapper::Resource | |
| property :id, Serial | |
| property :title, String | |
| property :lyrics, Text | |
| property :length, Integer | |
| property :released_on, Date | |
| end | |
| DataMapper.finalize | |
| get '/songs' do | |
| @songs = Song.all | |
| haml :songs | |
| end | |
| get '/songs/:id' do | |
| @song = Song.get(params[:id]) | |
| haml :show_song | |
| end | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment