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

ActiveSupport 3.2.6 modular extensions missing require #6896

Closed
iamvery opened this Issue Jun 28, 2012 · 7 comments

Comments

Projects
None yet
4 participants
Contributor

iamvery commented Jun 28, 2012

See https://gist.github.com/3012323

With ActiveSupport 3.2.3 I was able to require the active_support/core_ext/numeric/time by itself to get access to things like 4.minutes.ago, but doing the same in 3.2.6 throws an error in the ago method presumable because active_support/core_ext/time/zones is never required.

I tried for a bit to locate the appropriate location for the statement, but I'm not very familiar with the Rails source. I figured its an easy fix for someone who is...

Member

steveklabnik commented Jun 28, 2012

In general, requires map directly to files. So if active_support/core_ext/time/zones is not required, you can find that file in activesupport/lib/active_support/core_ext/time/zones.rb

Same thing with activesupport/lib/active_support/core_ext/numeric/time.rb

Contributor

iamvery commented Jun 28, 2012

I just noticed that even requiring the entire active_support/core_ext/numeric in 3.2.6 still causes the problem described. It looks like the only places that active_support/core_ext/time/zones is required is in the Date and DateTime extensions. Maybe it should probably be around in active_support/core_ext/time/calculations.rb?

I could be way off base, but I thought the whole design of ActiveSupport lent itself to being required in very small pieces to grab only what you need.

If you agree, I can put a pull request together for you if its worth it.

Thanks for you help :)

Member

steveklabnik commented Jun 28, 2012

I could be way off base, but I thought the whole design of ActiveSupport lent itself to being required in very small pieces to grab only what you need.

This is true, but it can get complicated. See a similar discussion over in #6884.

That said, I'm not sure if this is a bug or not, exactly. @fxn?

Contributor

iamvery commented Jun 28, 2012

I hear ya man. Thanks again for the speedy feedback!

@ghost ghost assigned fxn Jun 29, 2012

Contributor

mraaroncruz commented Jul 14, 2012

I think this is related.
In the docs it says that the rule of thumb to require classes is require 'active_support/core_ext/some_class'
This works for everything except for date, datetime and time.
Is there a reason for this?
I will try my best to add that pull request to this thread.

Contributor

mraaroncruz commented Jul 14, 2012

As I was working on the pull request - I noticed active_support/time
My pull request is ready. Is it redundant?
Thanks!

fxn added a commit that referenced this issue Jul 14, 2012

Merge pull request #7053 from pferdefleisch/activesupport-timely-requ…
…ires

Added time related req files to AS core_ext #6896
Owner

fxn commented Jul 14, 2012

I don't think so, AS core extensions follow that pattern of having a single entry point to group extensions to a given class, I believe we have better consistency with the files you sent.

@fxn fxn closed this in aa6f512 Jul 14, 2012

fxn added a commit that referenced this issue Jul 14, 2012

adds a missing require [fixes #6896]
This file uses Time.zone, which is defined in
active_support/core_ext/time/zones.rb.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment