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
test 1 |
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
# http://railscasts.com/episodes/126-populating-a-database | |
# http://github.com/ryanb/populator/tree/master | |
namespace :db do | |
task :populate => :environment do | |
require 'populator' # http://populator.rubyforge.org/ | |
require 'faker' # http://faker.rubyforge.org/rdoc/ | |
[User, Event, Link].each(&:delete_all) | |
def random(model) |
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
# config/initializers/log_protected_attribute_removal.rb | |
# raises an exception in test environment when trying to mass assign protected attributes | |
# detail: http://railspikes.com/2008/9/22/is-your-rails-application-safe-from-mass-assignment | |
if RAILS_ENV == 'test' | |
ActiveRecord::Base.class_eval do | |
def log_protected_attribute_removal(*attributes) | |
raise "Can't mass-assign these protected attributes: #{attributes.join(', ')}" | |
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
# Time zone issues with BJ, Rails, and UTC/local times? | |
# http://codeforpeople.rubyforge.org/svn/bj/trunk/README | |
# http://twitter.com/rubyist/statuses/957131155 | |
# http://twitter.com/technoweenie/statuses/957156761 | |
# config/initializers/bj_table_hack.rb | |
Bj::Table.class_eval do | |
def self.time_zone_aware_attributes | |
false |
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
~ $ sudo gem install merb | |
Password: | |
Building native extensions. This could take a while... | |
Successfully installed extlib-0.9.8 | |
Successfully installed thor-0.9.7 | |
Successfully installed merb-core-0.9.9 | |
Successfully installed merb-action-args-0.9.9 | |
Successfully installed merb-assets-0.9.9 | |
Successfully installed merb-auth-core-0.9.9 | |
Successfully installed merb-auth-more-0.9.9 |
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
~ $ sudo gem install rails | |
Password: | |
Successfully installed rails-2.1.1 | |
1 gem installed |
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 Foo | |
attr_accessor :bar | |
def initialize(bar) | |
@bar = bar | |
end | |
def doit | |
puts bar | |
bar = "*** #{bar} ***" |
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 'etc' | |
class Group | |
def foo | |
"hello" | |
end | |
end | |
class WTF < Struct.new(:var) | |
def foo |
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
# http://github.com/jnunemaker/httparty/ | |
require 'rubygems' | |
require 'httparty' | |
class Delicious | |
include HTTParty | |
base_uri 'https://api.del.icio.us/v1' | |
def initialize(u, p) | |
@auth = {:username => u, :password => p} |
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
# | |
# See also: http://almosteffortless.com/2008/12/11/easy-upload-via-url-with-paperclip/ | |
# | |
# Allow "uploads via url" with Rails and Paperclip | |
# | |
# http://www.thoughtbot.com/projects/paperclip | |
# http://github.com/thoughtbot/paperclip/tree/master | |
# http://groups.google.com/group/paperclip-plugin/browse_thread/thread/456401eb93135095 | |
# | |
# This example is designed to work with a "Photo" model that has an "Image" attachment |
OlderNewer