Hi ! 2005/12/5, Michael Koziarski <[EMAIL PROTECTED]>: > On 12/6/05, Francois Beausoleil <[EMAIL PROTECTED]> wrote: > > Hello all, > > > > I'd like to get a review of ticket #3005: > > http://dev.rubyonrails.org/ticket/3005 > > I like the general approach, How feasible is it to expand the > approach to handle columns called quote?
I implemented it, but I don't like it... Here's a taste of what the new code returns: ./script/../config/../vendor/rails/railties/lib/commands/runner.rb:27: Columns 'name', 'transaction', 'quote' have already been taken in models of class Game. You will have to rename your columns to not conflict with pre-existing method names. (ActiveRecord::ColumnNameAlreadyTaken) When I used name in my models, I never expected that to conflict. It's such a common one. Guess what it conflicts with: Class::name. Here's the implementation of the guard method: # Raise ActiveRecord::ColumnNameAlreadyTaken if one of the columns defined # in objects of this class conflict with pre-existing method names. def guard_against_duplicate_column_names # We cast a very wide net here, maybe we should not cast such as wide one ? methods = [ ActiveRecord::Base.methods, ActiveRecord::Base.instance_methods].flatten.compact.uniq duplicates = self.class.columns.select do |column| next false if column.name == self.class.primary_key methods.include?(column.name) end raise ActiveRecord::ColumnNameAlreadyTaken.new(duplicates, self.class) unless duplicates.empty? end Thoughts anyone ? -- François Beausoleil http://blog.teksol.info/
_______________________________________________ Rails-core mailing list Rails-core@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-core