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
var Post = Model('post', function () { | |
this.use(Model.Lunr(function () { | |
this.field('body') | |
this.field('title', { | |
'multiplier': 10 | |
}) | |
})) | |
}) |
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
var Bill = Model('bill', function () { | |
this.use(Model.validations) | |
this.validatesPresenceOf(['attribute1', 'attribute2']) | |
this.validatesPresenceOf('another_attribute', { | |
'condition': function () { | |
// some condition if you need it | |
return true | |
} | |
}) |
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
<script src="http://raphaeljs.com/raphael.js" type="text/javascript" charset="utf-8"></script> | |
<style type="text/css" media="screen"> | |
body { | |
background-color: black; | |
color: white; | |
font-family: helvetica; | |
} | |
#display { |
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 'rubygems' | |
require 'sinatra' | |
get "/" do | |
erb :index | |
end | |
get "/slow_network" do | |
sleep(2) | |
"Done" |
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 Admin::ReportsController < AdminController | |
respond_to :csv | |
def trips | |
respond_with TripReport.new | |
end | |
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
module ActiveModel | |
class Errors | |
def as_json(options=nil) | |
self | |
to_hash | |
end | |
def to_hash | |
hash = ActiveSupport::OrderedHash.new | |
each { |k, v| (hash[k] ||= []) << v } |
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
var User = Model('user', { | |
// class methods | |
validates: { | |
presenceOf: ['name'] | |
} | |
}, { | |
// instance methods | |
}) | |
o = new User ({name: "oliver"}) |
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
Post('post', {}, { | |
validatesPresenceOf: ['title', 'body'], | |
validatesLengthOf: [{attr: 'title', min: 20}, { attr: 'body', max: 2000 }] | |
}) |
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 'rubygems' | |
require 'rack' | |
require 'snippets' | |
require 'mongo' | |
require 'rackjson' | |
use Rack::JSON::Resource, :collections => [:notes], :db => Mongo::Connection.new.db("notes") | |
run lambda { |env| [404, {'Content-Length' => '9', 'Content-Type' => 'text/plain'}, "Not Found"] } |
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
Oliver-Nightingales-MacBook-Pro:capybara-envjs olivernightingale$ rake | |
(in /Users/olivernightingale/code/capybara-envjs) | |
warning: couldn't activate the debugging plugin, skipping | |
warning: couldn't activate the doofus plugin, skipping | |
warning: couldn't activate the git plugin, skipping | |
/Library/Ruby/Gems/1.8/gems/rspec-1.2.9/lib/spec/example/example_group_methods.rb:274:in `include_shared_example_group': Shared Example Group 'has_select' can not be found (RuntimeError) | |
from /Library/Ruby/Gems/1.8/gems/rspec-1.2.9/lib/spec/example/example_group_methods.rb:66:in `it_should_behave_like' | |
from /Library/Ruby/Gems/1.8/gems/rspec-1.2.9/lib/spec/example/example_group_methods.rb:65:in `each' | |
from /Library/Ruby/Gems/1.8/gems/rspec-1.2.9/lib/spec/example/example_group_methods.rb:65:in `it_should_behave_like' | |
from /Library/Ruby/Gems/1.8/gems/capybara-0.3.6/spec/session_spec.rb:58 |
NewerOlder