Ben Taitelbaum
Ben Taitelbaum

Reputation: 7403

Why are rails gems not using the same gem and library names?

Maybe it's just because it's late at night, but I just spent way too long figuring out that while the gem is activesupport, you need to require 'active_support'. This is the same for activerecord, actionmailer, and all the other rails libraries defined in https://github.com/rails/rails (so at least it's internally consistent).

Is there a historical reason for this, or any benefits to it?

Upvotes: 1

Views: 57

Answers (1)

squarism
squarism

Reputation: 3307

Historically, this change was a deprecation warning going to Rails 3 (started in Rails 2.3.2?). There is no real advantage or anything. It's legacy (yes confusing). You can see the commit here that adds the deprecation warnings: https://github.com/rails/rails/commit/08d15f86c447fea31132d11df03ff5df41650f50#diff-2

Devs cheering in the comments.

Really it was renaming (or zero'ing out) lib/activerecord.rb to lib/active_record.rb etc. That's the history and no one liked it. Lately, it's been less of a hot topic since most people have heard about it or run into by now. However, I'm sure I'd get this warning/error if I upgraded one of my really old Rails projects. Sorry if this was annoying for you, I've been there too. :)

Upvotes: 1

Related Questions