Skip to content

Instantly share code, notes, and snippets.

@Schniz
Created March 13, 2014 22:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Schniz/9538907 to your computer and use it in GitHub Desktop.
Save Schniz/9538907 to your computer and use it in GitHub Desktop.
Sinatra + Mongoid = ♥
development:
sessions:
default:
database: sinatraStam_test
hosts:
- localhost:27017
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
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