Closed kalashnikovisme closed 10 years ago
Hi. Term
is provided by the term-ansicolor
gem, which is a dependency of Tconsole.
To avoid the collision I think you've got two options. 1) Move your class into a module, or 2) rename your class.
Given the way Rails makes assumptions about the names of classes when you setup relationships between models, I'd favour (2) myself.
I consider this a failing of Ruby to be honest; there isn't enough encouragement for people to use namespaces, so most things live in the global namespace. :-(
I think that changing app architecture for compatibility with test lib or framework is not good practice. Please, see pull request on this subject. https://github.com/gma/tconsole/pull/79
This isn't term-ansicolor's fault, or problem to deal with, in my opinion. Rails really ought to namespace all your code in a module named after your app, and Ruby ought to make that approach more appealing (i.e. Ican see why Rails doesn't do this).
I don't think going round renaming globals in all the other projects in the world that use a library is a cost effective solution. People will have written code that uses term-ansicolor that refers to the Term module. You're asking them to patch their projects so you don't have to rename a class/table.
What if somebody else has a class called Termin? And what happens when you want to give a class the same name as something in Ruby's standard library. I'm afraid renaming or namespacing in your Rails app is still my favoured solution.
I also bet there are more gems with a Term module in. Do we patch all those too? Where would it end?
And I don't want to split hairs, but I'm not suggesting you change your app architecture so you can use a testing tool. I'm just suggesting that you rename a class and table so that your choice doesn't conflict with existing use of the word that is already in use (globally).
Sorry to be the bearer of bad news, but I'm not sold on this approach.
On 16 May 2014, at 23:47, Павел Калашников notifications@github.com wrote:
I think that changing app architecture for compatibility with test lib or framework is not good practice. Please, see pull request on this subject.
79
— Reply to this email directly or view it on GitHub.
I have the model named Term.
But in TConsole returned me the error:
similar situation with all ActiveRecord functions.
What should I do?