[Rails-core] #3005 - Prevent duplicate names
Francois Beausoleil
francois.beausoleil at gmail.com
Wed Dec 7 21:23:42 GMT 2005
2005/12/7, Michael Koziarski <michael at koziarski.com>:
> Why are you taking the class methods as well? Column names won't
> conflict with class methods.
Because you won't be able to start a transaction on a model instance otherwise:
Game.find(1).transaction do
# Do stuff on game
end
I verified which #transaction method would be called. It was
ActiveRecord::Base.transaction, a class method. Here's a little test
I made:
$ type check.rb
p = proc do |event, file, line, id, binding, classname|
if id.to_s =~ /transaction/ then
printf "%8s %s:%-2d %10s %8s\n", event, file, line, id, classname
end
end
g = Game.new
set_trace_func p
g.transaction do
puts "In transaction"
end
set_trace_func nil
$ ruby script\runner "require 'check'"
call ./script/../config/../vendor/rails/activerecord/lib/active_record/transactions.rb:117
transaction ActiveRecord::Transactions
...
In transaction
return ./check.rb:10 transaction ActiveRecord::Transactions::ClassMethods
So, we do in fact have to gobble up the class methods. Maybe this is
an instance of Ruby being too helpful ?
Bye !
--
François Beausoleil
http://blog.teksol.info/
More information about the Rails-core
mailing list