Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

examples in classic and modular style

  • Loading branch information...
commit d43a2922ab3d5fec063a1cb43a59eeed95ed765f 1 parent 14d76c7
Jordan West authored

Showing 2 changed files with 46 additions and 0 deletions. Show diff stats Hide diff stats

  1. +22 0 examples/classic.rb
  2. +24 0 examples/modular.rb
22 examples/classic.rb
... ... @@ -0,0 +1,22 @@
  1 +$: << File.join(File.dirname(__FILE__), %w/.. lib/)
  2 +require 'sinatra'
  3 +require 'sinatra/mongomatic'
  4 +
  5 +mongomatic nil
  6 +
  7 +class User < Mongomatic::Base
  8 +
  9 +end
  10 +
  11 +get '/create/:name' do
  12 + User.new(:name => params[:name]).insert
  13 + "ok"
  14 +end
  15 +
  16 +get '/all' do
  17 + User.find.inject("") do |list, user|
  18 + list += "#{user[:name]}<br>"
  19 + end
  20 +end
  21 +
  22 +
24 examples/modular.rb
... ... @@ -0,0 +1,24 @@
  1 +$: << File.join(File.dirname(__FILE__), %w/.. lib/)
  2 +require 'sinatra/base'
  3 +require 'sinatra/mongomatic'
  4 +
  5 +class User < Mongomatic::Base
  6 +end
  7 +
  8 +class MongomaticExample < Sinatra::Base
  9 + register Sinatra::Mongomatic
  10 +
  11 + mongomatic nil
  12 +
  13 + get '/create/:name' do
  14 + User.new(:name => params[:name]).insert
  15 + "ok"
  16 + end
  17 +
  18 + get '/all' do
  19 + User.find.inject("") do |list, user|
  20 + list += "#{user[:name]}<br>"
  21 + end
  22 + end
  23 + run! if $0 == __FILE__
  24 +end

0 comments on commit d43a292

Please sign in to comment.
Something went wrong with that request. Please try again.