Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

update doc: MIME::Types#index_extensions is deprecated and will be private. #1737

Closed
zhangpy opened this issue Dec 21, 2014 · 8 comments
Closed

Comments

@zhangpy
Copy link

zhangpy commented Dec 21, 2014

The warning shows up when I copy it from document.
But I don't find method to avoid it

mime-types (2.4.3)

@sb89
Copy link

sb89 commented Feb 12, 2015

I've come across this too, what should be used instead?

@mehulkar
Copy link

anyone find a solution to this yet?

@tute
Copy link
Contributor

tute commented May 20, 2015

Related ruby-mime-types issue: mime-types/ruby-mime-types#88

It seems there will be no replacement. Should we remove it from the README? Or how can we update the docs, to solve that issue with different calls?

@mehulkar
Copy link

Wondering if anyone has worked around this or come to a resolution yet?

@tute
Copy link
Contributor

tute commented Oct 4, 2015

@jyurek?

@moritzschepp
Copy link

Instead of

text_plain = MIME::Types["text/plain"].first
text_plain.extensions << "foo"
MIME::Types.index_extensions text_plain

it seems you can use

text_plain = MIME::Types["text/plain"].first
text_plain.add_extensions "foo"

@bdewater
Copy link
Contributor

bdewater commented Mar 8, 2016

On mime-types 2.99.1 I still need to index_extensions method call but that gives a deprecation warning. The example in #1924 (comment) by wrkrb33 seems like the better way of solving this.

@aCandidMind
Copy link

Isn't the old way of adding extensions but using the current v3.1 API less error-prone than the content_type_mappings in that you don't have to specify all (sometimes OS-dependent) MIME types for the desired extensions? Note that in wrkrb33's solution already linked to above, all zip MIME types had to be explicitly mentioned. Or the other problems mentioned in that same thread.

Here's the relevant mime_types changelog entry for 3.0, which indicates there's now an API that suits paperclip's use case.

When extensions are set or modified with add_extensions, the primary registry will be informed of a need to reindex extensions. Resolves #84.

from
https://github.com/mime-types/ruby-mime-types/blob/master/History.rdoc#30--2015-11-21

add_extensions now in turn calls reindex_extensions
https://github.com/mime-types/ruby-mime-types/blob/v3.1/lib/mime/type.rb#L244

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants