Skip to content

Instantly share code, notes, and snippets.

Method Uses Default Accessor Validations Callbacks Touches updated_at Readonly check
update
update_attributes
update_columns
User::update
User::update_all
namespace :db do
desc "Convert your database into seeds!"
task :export_seeds => :environment do
Rails.application.eager_load!
models = ObjectSpace.each_object(Class).select { |c| c < ActiveRecord::Base }
ignored_keys = %w[created_at updated_at id]
models.each do |model|
puts "### #{model}s ######################################"
@epitron
epitron / problem.txt
Last active August 29, 2015 14:16 — forked from foucist/quiz.rb
Multi-replace problem
QUESTION 6: Write a function multi_gsub that performs multiple, simultaneous
search-and-replace operations on a string.
Example:
"Lorem Ipsum #9191".multi_gsub([[/[a-z]/i, '#'], [/#/, 'P']])
=> "##### ##### P9191"
config.gem "rspec", :lib => false
config.gem "rspec-rails", :lib => false
config.gem "cucumber", :lib => false
config.gem "thoughtbot-factory_girl", :lib => false, :source => "http://gems.github.com"
config.gem "faker", :lib => false
config.gem "carlosbrando-remarkable", :lib => "remarkable", :source => "http://gems.github.com"
config.gem "haml"
config.gem "webrat"
config.gem "htmlentities"
config.gem "json"
@epitron
epitron / frozen_stuff.rb
Created November 10, 2008 13:38 — forked from Sutto/frozen_stuff.rb
undefined
require 'rubygems'
# Only load paths from the folder 'gems' under the current
# dir - e.g. ./gems/
# To freeze use gem install <name> -i gems
Gem.clear_paths
File dsl
Gem.path.unshift (PWD / 'gems').absolute_path
end