- Item
- Item
- DIGITAL-XYZ
(optional)
module ActiveRecord::ConnectionAdapters::SchemaStatements | |
def add_index_with_quiet(table_name, column_names, options = {}) | |
quiet = options.delete(:quiet) | |
add_index_without_quiet table_name, column_names, options | |
rescue | |
raise unless quiet and $!.message =~ /^Index name '.*' on table '#{table_name}' already exists/i | |
puts "Failed to create index #{table_name} #{column_names.inspect} #{options.inspect}" | |
end | |
alias_method_chain :add_index, :quiet |
class Address < ActiveRecord::Base | |
has_many :phonings, :as => :phonable | |
has_many :phone_numbers, :through => :phonings | |
accepts_nested_attributes_for :phonings, :allow_destroy => true | |
end |
class Address < ActiveRecord::Base | |
has_many :phonings, :as => :phonable | |
has_many :phone_numbers, :through => :phonings | |
accepts_nested_attributes_for :phonings, :allow_destroy => true | |
end | |
class Person < ActiveRecord::Base | |
has_many :phonings, :as => :phonable |
ruby-1.9.2-p136 :001 > j = Job.last | |
ruby-1.9.2-p136 :002 > j.file_data.file.gridio.class | |
=> Mongo::GridIO | |
ruby-1.9.2-p136 :003 > CSV.new(j.file_data.file.gridio) | |
NoMethodError: undefined method `pos' for #<GridIO _id: 4d5cbe235ef0dbcaf2000001> | |
from /Users/rchristie/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/csv.rb:2011:in `init_separators' | |
from /Users/rchristie/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/csv.rb:1570:in `initialize' | |
from (irb):3:in `new' | |
from (irb):3 | |
from /Users/rchristie/dev/cast/vendor/ruby/1.9.1/gems/railties-3.0.4/lib/rails/commands/console.rb:44:in `start' |
#-*-Ruby-*- | |
require 'rubygems' | |
require 'pp' | |
require 'wirble' | |
require 'hirb' | |
require 'ap' | |
if RUBY_VERSION[0..2] == "1.9" | |
require 'flyrb' | |
else | |
require 'utility_belt' |
# added a new before_validation | |
PhoneNumber.all { |p| p.save! } | |
# doesn't resave the data... silly me | |
ActiveRecord::Base.partial_updates = false | |
PhoneNumber.all { |p| p.valid?; p.save! } |
klass = Paperclip::Storage::Filesystem | |
klass.module_eval do | |
def flush_writes #:nodoc: | |
logger.info("[paperclip-hack] Writing files for #{name}") | |
@queued_for_write.each do |style, file| | |
file.close | |
FileUtils.mkdir_p(File.dirname(path(style))) | |
logger.info("[paperclip-hack] -> #{path(style)}") | |
FileUtils.cp(file.path, path(style)) |