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
system: | |
system: | |
uname: "Darwin petes-macbook.home 9.8.0 Darwin Kernel Version 9.8.0: Wed Jul 15 16:55:01 PDT 2009; root:xnu-1228.15.4~1/RELEASE_I386 i386" | |
bash: "/bin/bash => GNU bash, version 3.2.17(1)-release (i386-apple-darwin9.0)" | |
zsh: "/bin/zsh => zsh 4.3.4 (i386-apple-darwin9.0)" | |
rvm: | |
version: "rvm 1.0.9 by Wayne E. Seguin (wayneeseguin@gmail.com) [http://rvm.beginrescueend.com/]" |
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 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
Rabl.render(Event.first, 'events/event') |
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
namespace :data do | |
desc "scrubs all strings in every table" | |
task :scrub => :environment do | |
unless Rails.env.development? | |
raise "This should only ever be run in development!" | |
end | |
tables = ActiveRecord::Base.connection.tables - ["schema_migrations"] |
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 MyApp | |
module RakeData | |
extend Self | |
HILARIOUS_STRING = 'Gangster lorem ipsum from http://lorizzle.nl/' | |
def tables | |
["list", "of", "table", "names"] | |
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
namespace :data do | |
MyApp::RakeData.tables.each do |table| | |
desc "scrubs #{table} table data" | |
task "scrub_#{table}" do | |
string_attributes = table.classify.constantize.columns.map {|c| c.name if [:string, :text].include?(c.type) }.compact | |
setters = [] | |
update_string = "UPDATE #{table} SET " | |
string_attributes.each do |attribute| |
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: | |
adapter: mysql2 | |
encoding: utf8 | |
database: my_db | |
pool: 20 | |
username: | |
password: |
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 PreviouslyDirty | |
extend ActiveSupport::Concern | |
included do | |
attribute_method_suffix '_previously_changed?' | |
end | |
private | |
# Handle <tt>*_previously_changed?</tt> for +method_missing+. |
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
> user = User.first | |
> user.name | |
=> "Frank" | |
> user.name = "John" | |
> user.name_changed? | |
=> true | |
> user.name_change | |
=> ["Frank", "John"] |
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
> user.name = "John" | |
> user.save | |
> user.previous_changes | |
=> {"name"=>["Frank", "John"]} |
OlderNewer