Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix NameError: uninitialized constant Mime::JS in Rails 5.1.0 beta #627

Merged
merged 1 commit into from
Mar 13, 2017
Merged

Fix NameError: uninitialized constant Mime::JS in Rails 5.1.0 beta #627

merged 1 commit into from
Mar 13, 2017

Conversation

ryu39
Copy link
Contributor

@ryu39 ryu39 commented Mar 11, 2017

Thank you for your nice gem.

I found Travis CI tests with Rails edge(5.1.0 beta) gemfile are failed by NameError: uninitialized constant Mime::JS.

In Rails 5.1.0 beta, ::Mime::JS and other constants are removed by this PR.

I fixed this problem using ::Mime[:js].

But in Rails 2.3, ::Mime[:js] cannot be used because ::Mime.[] is not defined.
So I checked ::Mime.[] is defined or not using respond_to?, and if ::Mime.[] is not defined, then I use ::Mime::JS.

Please check my PR.
Thank you.

* ::Mime::JS is deprecated in Rails 5.0.x and removed in 5.1.0 beta.
  Instead of using ::Mime::JS, ::Mime[:js] is recommended. So I use this.
* But in Rails 2.3, ::Mime[] is not defined and raise NoMethodError.
  So I check that ::Mime[] is defined using respond_to?, and if not
  defined, then use ::Mime::JS.
@unixmonkey unixmonkey merged commit 2b429c7 into mileszs:master Mar 13, 2017
@unixmonkey
Copy link
Collaborator

Sweet. Thanks for this!

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

Successfully merging this pull request may close these issues.

3 participants