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

Already on GitHub? Sign in to your account

Problems with model named Tag on master #7714

Closed
slbug opened this Issue Sep 20, 2012 · 6 comments

Comments

Projects
None yet
5 participants
Contributor

slbug commented Sep 20, 2012

class Tag < ActiveRecord::Base
end

class TagType < ActiveRecord::Base

  def some_method
    Tag.find_by_name('something') # => NoMethodError: undefined method `find_by_name' for ActiveRecord::Model::Tag:Module
  end

end

I think users should get warning about it. Something like use ::Tag...

Member

steveklabnik commented Sep 20, 2012

I'm not sure that we can give this a good warning.

Owner

rafaelfranca commented Sep 20, 2012

Maybe we can rename the Tag module inside ActiveRecord::Model since it only to detect if ActiveRecord::Model is present. cc @jonleighton

Member

jonleighton commented Sep 20, 2012

We should rename it to ActiveRecord::Tag rather than the currenct ActiveRecord::Model::Tag. Then it won't resolve inside the class. Anyone want to make a patch?

Contributor

frodsan commented Sep 20, 2012

Me \o.

Member

jonleighton commented Sep 20, 2012

@frodsan hero!

Contributor

frodsan commented Sep 20, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment