This file contains hidden or 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
--- | |
:benchmark: false | |
:verbose: true | |
:update_sources: true | |
gem: --no-ri --no-rdoc | |
:sources: | |
- http://gemcutter.org | |
- http://gems.rubyforge.org/ | |
:backtrace: false | |
:bulk_threshold: 1000 |
This file contains hidden or 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
/Library/Ruby/Gems/1.8/gems/haml-3.0.7/lib/sass/scss/rx.rb:49: warning: already initialized constant H | |
/Library/Ruby/Gems/1.8/gems/haml-3.0.7/lib/sass/scss/rx.rb:50: warning: already initialized constant NL | |
/Library/Ruby/Gems/1.8/gems/haml-3.0.7/lib/sass/scss/rx.rb:51: warning: already initialized constant UNICODE | |
/Library/Ruby/Gems/1.8/gems/haml-3.0.7/lib/sass/scss/rx.rb:57: warning: already initialized constant NONASCII | |
/Library/Ruby/Gems/1.8/gems/haml-3.0.7/lib/sass/scss/rx.rb:58: warning: already initialized constant ESCAPE | |
/Library/Ruby/Gems/1.8/gems/haml-3.0.7/lib/sass/scss/rx.rb:59: warning: already initialized constant NMSTART | |
/Library/Ruby/Gems/1.8/gems/haml-3.0.7/lib/sass/scss/rx.rb:60: warning: already initialized constant NMCHAR | |
/Library/Ruby/Gems/1.8/gems/haml-3.0.7/lib/sass/scss/rx.rb:61: warning: already initialized constant STRING1 | |
/Library/Ruby/Gems/1.8/gems/haml-3.0.7/lib/sass/scss/rx.rb:62: warning: already initialized constant STRING2 | |
/Library/Ruby/Gems/1.8/gems/haml-3.0.7/lib/sass/scss/rx |
This file contains hidden or 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
# Add a new child to this person | |
@person.children_attributes = [ { :name => 'Son' } ] | |
@person.children #=> [ <#Person: name: 'Son'> ] | |
@person.children.clear | |
# Add two new children to this person | |
@person.children_attributes = | |
[ { :name => 'Son' }, { :name => 'Daughter' } ] | |
@person.save | |
@person.children #=> [ <#Person: name: 'Son'>, <#Person: name: 'Daughter'> ] |
This file contains hidden or 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' | |
require 'data_mapper' | |
require 'dm-sqlite-adapter' | |
DataMapper.setup(:default, "sqlite3://" + '/tmp/development.db') | |
class Post | |
include DataMapper::Resource | |
This file contains hidden or 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
@entry = Entry.find_or_create_by(:link => something.url) | |
@entry.update_attributes(:title => title, :body => content, :site_id => site_ids[url] |
This file contains hidden or 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 'carrierwave/orm/mongoid' | |
class Photo | |
include Mongoid::Document | |
include Mongoid::Timestamps # adds created_at and updated_at fields | |
# fields | |
field :caption, :type => String | |
mount_uploader :file, Uploader | |
end |
This file contains hidden or 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
def test(options={}) | |
Class.new | |
puts 'testing the gist' | |
end |
This file contains hidden or 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
Mongoid.database = case Padrino.env | |
when :development | |
Mongo::Connection.from_uri("mongodb://user:[email protected]:27048/development_db").db('development_db') | |
when :production | |
Mongo::Connection.from_uri("mongodb://user:[email protected]:27048/production_db").db('production_db') | |
when :test | |
Mongo::Connection.new('localhost',Mongo::Connection::DEFAULT_PORT).db('test_db') | |
end |
This file contains hidden or 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
get %r{/\w+/} do | |
"Hello!" | |
end | |
get '/call/:number', :number => /\d+/ do | |
"Call #{params[:number]}" | |
end | |
get '/regex/:route/:data', :route => /\w+/, :data => /\d+/ do | |
"Route: #{params[:route]}, Data: #{params[:data]}" |
This file contains hidden or 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
# In your gemfile, add will_paginate. | |
# We are using the latest ActiveRecord(3.0.x) | |
# As of this gist, the version for will_paginate is 2.3.15, we want 3.x version | |
## Gemfile | |
gem 'will_paginate', '3.0.pre2' | |
# In config/boot.rb, enable activerecord in Padrino.after_load. |