Created
March 13, 2014 22:55
-
-
Save Schniz/9538907 to your computer and use it in GitHub Desktop.
Sinatra + Mongoid = ♥
This file contains 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
development: | |
sessions: | |
default: | |
database: sinatraStam_test | |
hosts: | |
- localhost:27017 |
This file contains 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 'mongoid' | |
require 'sinatra' | |
Mongoid.load! './mongoid.yml' | |
# Load the class "Song" | |
require './song' | |
# Pretty self explainatory... | |
get "/" do | |
"welcome to my crib fella" | |
end | |
get "/songs" do | |
Song.all.to_json | |
end | |
get "/songs/:song_id" do |song_id| | |
Song.find(song_id).to_json | |
end |
This file contains 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
class Song | |
include Mongoid::Document | |
field :title, type: String | |
field :lyrics, type: String | |
field :saved_by, type: String | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment