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
development: &global_settings | |
database: textual_development | |
host: 127.0.0.1 | |
port: 27017 | |
test: | |
database: textual_test | |
<<: *global_settings | |
production: |
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 Rack | |
class FirebugLogger | |
def initialize(app, options = {}) | |
@app = app | |
@options = options | |
end | |
def call(env) | |
status, headers, orig_response = @app.call(env) | |
return [status, headers, orig_response] unless (headers["Content-Type"] =~ /html/ && env['firebug.logs']) |
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
This plugin for Merb and Rails provides a simple and extremely flexible way to upload files. | |
ORM Support: ActiveRecord, DataMapper, Sequel, MongoMapper | |
Storage Support: S3, MongoDB's GridFS, filesystem... | |
Oh yeah and works with RMagick, ImageScience, MiniMagic | |
http://github.com/jnicklas/carrierwave/ |
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
# The basic idea is that we take the existing data via ActiveRecord | |
# and create new documents in MongoDB using MongoMapper. | |
# This method is necessary as we want to keep all the associations of existing dataset | |
# and by the way, clean up empty columns | |
# We rely on models still being ActiveRecord::Base, I bet you can figure out how the look like. | |
# And have the newer MongoDB ones here in a module, painful as we have to set the collection_name | |
# Don't put a +timestamps!+ into your MongoMapper models yet because this would change the updated_at if existing | |
# As you see in the MongoDB models, a few loose their indepence, e.g. Source as I | |
# plan to add other sources besides flickr, or Page and Album which only make sense in | |
# their parent Website |
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
# part of config/enviroment.rb | |
... | |
Rails::Initializer.run do |config| | |
# Load model files from sub folders | |
config.load_paths += Dir["#{RAILS_ROOT}/app/models/*"].find_all { |f| File.stat(f).directory? } | |
# Load middleware - initially used by flash-session-hack | |
config.load_paths << "#{RAILS_ROOT}/app/middleware" |
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
## | |
# CarrierWave Amazon S3 File Reprocessor Rake Task | |
# | |
# Written (specifically) for: | |
# - CarrierWave | |
# - Ruby on Rails 3 | |
# - Amazon S3 | |
# | |
# Works with: | |
# - Any server of which you have write-permissions in the Rails.root/tmp directory |
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
=Navigating= | |
visit('/projects') | |
visit(post_comments_path(post)) | |
=Clicking links and buttons= | |
click_link('id-of-link') | |
click_link('Link Text') | |
click_button('Save') | |
click('Link Text') # Click either a link or a button | |
click('Button Value') |
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
#testing the speed of creating a new object via the association with mongoid | |
c = Club.first | |
####### 43 seconds ####### | |
begin | |
500.times do |i| | |
c.people.create(:name => 'Jim') | |
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
FactoryGirl.define do | |
sequence :email do |n| | |
"user#{n}@example.com" | |
end | |
factory :user do | |
password "test" | |
aliased_as :author | |
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
# Basic tagging system for mongoid documents. | |
# jpemberthy 2010 | |
# | |
# class User | |
# include Mongoid::Document | |
# include Mongoid::Document::Taggable | |
# end | |
# | |
# @user = User.new(:name => "Bobby") | |
# @user.tag_list = "awesome, slick, hefty" |
OlderNewer