Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Initital init

  • Loading branch information...
commit 1b056f8ea7c03bcd5c947e311c9ecf35626e3d23 0 parents
@runemadsen authored
7 Gemfile
@@ -0,0 +1,7 @@
+source "http://gemcutter.org"
+source :rubygems
+
+gem "sinatra"
+gem "mysql"
+gem "activerecord"
+gem "sinatra-activerecord", :require => "sinatra/activerecord"
35 Gemfile.lock
@@ -0,0 +1,35 @@
+GEM
+ remote: http://gemcutter.org/
+ remote: http://rubygems.org/
+ specs:
+ activemodel (3.0.4)
+ activesupport (= 3.0.4)
+ builder (~> 2.1.2)
+ i18n (~> 0.4)
+ activerecord (3.0.4)
+ activemodel (= 3.0.4)
+ activesupport (= 3.0.4)
+ arel (~> 2.0.2)
+ tzinfo (~> 0.3.23)
+ activesupport (3.0.4)
+ arel (2.0.9)
+ builder (2.1.2)
+ i18n (0.5.0)
+ mysql (2.8.1)
+ rack (1.2.2)
+ sinatra (1.2.1)
+ rack (~> 1.1)
+ tilt (< 2.0, >= 1.2.2)
+ sinatra-activerecord (0.1.3)
+ sinatra (>= 0.9.4)
+ tilt (1.2.2)
+ tzinfo (0.3.25)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ activerecord
+ mysql
+ sinatra
+ sinatra-activerecord
2  Rakefile
@@ -0,0 +1,2 @@
+require 'index.rb'
+require 'sinatra/activerecord/rake'
2  config.ru
@@ -0,0 +1,2 @@
+require 'index'
+run Sinatra::Application
11 db/migrate/20110412175929_create_images.rb
@@ -0,0 +1,11 @@
+class CreateImages < ActiveRecord::Migration
+ def self.up
+ create_table :images do |t|
+ t.string :url
+ end
+ end
+
+ def self.down
+ drop_table :images
+ end
+end
9 index.rb
@@ -0,0 +1,9 @@
+require 'rubygems'
+require 'bundler'
+Bundler.require
+require 'models'
+
+get '/' do
+ erb :hello
+end
+
4 models.rb
@@ -0,0 +1,4 @@
+set :database, 'mysql://user:password@localhost/dbname'
+
+class Image < ActiveRecord::Base
+end
3  views/hello.erb
@@ -0,0 +1,3 @@
+<h1>Sinatra Activerecord Bundler Example</h1>
+
+Hello there! There are <% Image.all.count %> images in your database.
11 views/layout.erb
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<head></head>
+
+<body>
+
+ <%= yield %>
+
+</body>
+</html>
+
+
Please sign in to comment.
Something went wrong with that request. Please try again.