Conflict

Hi all,
How to avoid class name conflict in model class and gem class name if both
same??
Example:1) Model class Country
2) gem countries have Country class

When application runs it always take gems countries class Country, where I
have used model country. And gives model query error.

Change the name of your class to something that resembles country, something like area, or state

···

Sent from my iPhone

On Nov 23, 2015, at 8:26 PM, Indrajeet Mishra <indrajeetmishra7590@gmail.com> wrote:

Hi all,
How to avoid class name conflict in model class and gem class name if both same??
Example:1) Model class Country
2) gem countries have Country class

When application runs it always take gems countries class Country, where I have used model country. And gives model query error.

I have used another gem to resolved the problem, my question is how we can
resolve if there is no alternatives.

···

On Nov 24, 2015 8:00 AM, "thomas Perkins" <thomas.perkins23@icloud.com> wrote:

Change the name of your class to something that resembles country,
something like area, or state

Sent from my iPhone

On Nov 23, 2015, at 8:26 PM, Indrajeet Mishra < > indrajeetmishra7590@gmail.com> wrote:

Hi all,
How to avoid class name conflict in model class and gem class name if both
same??
Example:1) Model class Country
2) gem countries have Country class

When application runs it always take gems countries class Country, where I
have used model country. And gives model query error.

Is it not the case that you CAN enforce the use of the correct class by using explicit naming i.e. "namespace::classname"?
That, at least, is my understanding of the documentation. Are there cases where this approach will not work?

···

On 24/11/2015 2:26 AM, Indrajeet Mishra wrote:

Hi all,
How to avoid class name conflict in model class and gem class name if both same??
Example:1) Model class Country
2) gem countries have Country class

When application runs it always take gems countries class Country, where I have used model country. And gives model query error.

No virus found in this message.
Checked by AVG - www.avg.com <http://www.avg.com>
Version: 2015.0.6176 / Virus Database: 4460/11058 - Release Date: 11/24/15

--
Patrick Bayford Tel : 020 8265 8376 E-mail : pbayford@talktalk.net

-----
No virus found in this message.
Checked by AVG - www.avg.com
Version: 2015.0.6176 / Virus Database: 4460/11058 - Release Date: 11/24/15

They shouldn't clash as long as you call them separately

···

Sent from my iPhone

On Nov 23, 2015, at 8:34 PM, Indrajeet Mishra <indrajeetmishra7590@gmail.com> wrote:

I have used another gem to resolved the problem, my question is how we can resolve if there is no alternatives.

On Nov 24, 2015 8:00 AM, "thomas Perkins" <thomas.perkins23@icloud.com> wrote:
Change the name of your class to something that resembles country, something like area, or state

Sent from my iPhone

On Nov 23, 2015, at 8:26 PM, Indrajeet Mishra <indrajeetmishra7590@gmail.com> wrote:

Hi all,
How to avoid class name conflict in model class and gem class name if both same??
Example:1) Model class Country
2) gem countries have Country class

When application runs it always take gems countries class Country, where I have used model country. And gives model query error.

Have you tried using a module as namespace <https://rubymonk.com/learning/books/1-ruby-primer/chapters/35-modules/lessons/80-modules-as-namespaces> over your model Country class?

shreyas

···

On Nov 24, 2015, at 8:04 AM, Indrajeet Mishra <indrajeetmishra7590@gmail.com> wrote:

I have used another gem to resolved the problem, my question is how we can resolve if there is no alternatives.

On Nov 24, 2015 8:00 AM, "thomas Perkins" <thomas.perkins23@icloud.com <mailto:thomas.perkins23@icloud.com>> wrote:
Change the name of your class to something that resembles country, something like area, or state

Sent from my iPhone

On Nov 23, 2015, at 8:26 PM, Indrajeet Mishra <indrajeetmishra7590@gmail.com <mailto:indrajeetmishra7590@gmail.com>> wrote:

Hi all,
How to avoid class name conflict in model class and gem class name if both same??
Example:1) Model class Country
2) gem countries have Country class

When application runs it always take gems countries class Country, where I have used model country. And gives model query error.

Thanks to all

···

On Nov 24, 2015 8:27 AM, "thomas Perkins" <thomas.perkins23@icloud.com> wrote:

They shouldn't clash as long as you call them separately

Sent from my iPhone

On Nov 23, 2015, at 8:34 PM, Indrajeet Mishra < > indrajeetmishra7590@gmail.com> wrote:

I have used another gem to resolved the problem, my question is how we can
resolve if there is no alternatives.
On Nov 24, 2015 8:00 AM, "thomas Perkins" <thomas.perkins23@icloud.com> > wrote:

Change the name of your class to something that resembles country,
something like area, or state

Sent from my iPhone

On Nov 23, 2015, at 8:26 PM, Indrajeet Mishra < >> indrajeetmishra7590@gmail.com> wrote:

Hi all,
How to avoid class name conflict in model class and gem class name if
both same??
Example:1) Model class Country
2) gem countries have Country class

When application runs it always take gems countries class Country, where
I have used model country. And gives model query error.

Sometimes you can do this, but it can be difficult in a Rails app, since Rails brings expectations about a correspondence between directory/file names and class names.

In the riak-client gem I develop at work, there’s a `Riak::Crdt::Set` class that also uses the standard library `::Set` class, which is, of course, confusing. I have to refer to them with those names (i.e. I can’t just use `Set` ever) in both [code](https://github.com/basho/riak-ruby-client/blob/f1ffbff7dad4dad487103560cc9c06f7abffedd7/lib/riak/crdt/set.rb) and [documentation](http://basho.github.io/riak-ruby-client/crdt.html#toc-sets) to keep both myself and any readers from getting confused.

Bryce

···

On 24 Nov 2015, at 16:31, Patrick Bayford wrote:

Is it not the case that you CAN enforce the use of the correct class by using explicit
naming i.e. "namespace::classname"?
That, at least, is my understanding of the documentation. Are there cases where this approach will not work?

Thanks for that Bryce - I'm NOT fluent in Rails! That will teach me to read the question!

···

On 25/11/2015 1:57 AM, Bryce Kerley wrote:

On 24 Nov 2015, at 16:31, Patrick Bayford wrote:

    Is it not the case that you CAN enforce the use of the correct
    class by using explicit
    naming i.e. "namespace::classname"?
    That, at least, is my understanding of the documentation. Are
    there cases where this approach will not work?

Sometimes you can do this, but it can be difficult in a Rails app, since Rails brings expectations about a correspondence between directory/file names and class names.

In the riak-client gem I develop at work, there’s a |Riak::Crdt::Set| class that also uses the standard library |::Set| class, which is, of course, confusing. I have to refer to them with those names (i.e. I can’t just use |Set| ever) in both code <https://github.com/basho/riak-ruby-client/blob/f1ffbff7dad4dad487103560cc9c06f7abffedd7/lib/riak/crdt/set.rb> and documentation <http://basho.github.io/riak-ruby-client/crdt.html#toc-sets> to keep both myself and any readers from getting confused.

Bryce

--
Patrick Bayford Tel : 020 8265 8376 E-mail : pbayford@talktalk.net

-----
No virus found in this message.
Checked by AVG - www.avg.com
Version: 2015.0.6176 / Virus Database: 4460/11065 - Release Date: 11/25/15

Don’t date all women named “mary”.

Always personalize your classes and methods to be unique. Always. Security is very very good. Use that even in the placement of where you question if it is needed.

Rule: Never even approach using names that are so obvious.

···

On Nov 24, 2015, at 12:08 AM, Indrajeet Mishra <indrajeetmishra7590@gmail.com> wrote:

Thanks to all

Cheers, Bee