Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Term::ANSIColor::Attribute#underscore #29

Closed
HoneyryderChuck opened this issue Jul 1, 2016 · 0 comments
Closed

Remove Term::ANSIColor::Attribute#underscore #29

HoneyryderChuck opened this issue Jul 1, 2016 · 0 comments

Comments

@HoneyryderChuck
Copy link

I think that this method should be gone, for two reasons:

  • it's an alias for underline, the real ANSI method
  • it conflicts with the DB table name inflectors around.

This is typical for the name where one monkey-patches String class with the Term::ANSIColor module. By doing this, one changes the behaviour expected by most ORMs, namely ActiveRecord and Sequel. I've seen this break with Sequel and ActiveRecord 2 (No known reports from ActiveRecord 3, but I assume that it will break nonetheless if the include is done before requiring activerecord, which rarely happens).

Example:

require 'sequel'
require 'logger'
require 'term/ansicolor'

String.send :include, Term::ANSIColor

DB = Sequel.sqlite
DB.loggers = [Logger.new(STDOUT)]

DB.create_table :cars do
  primary_key :id
end

class Car < Sequel::Model

end

puts "table name is #{Car.table_name}"

DB.drop_table :cars
silkeh added a commit to silkeh/term-ansicolor that referenced this issue Feb 15, 2018
The underscore method conflicts with String.underscore from Rails.

Closes flori#29
@flori flori closed this as completed Nov 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants