Skip to content

Conversation

@mattbrictson
Copy link
Contributor

In Rails 5, alias_method_chain is deprecated in favor of Module.prepend. However, prepend is only available in Ruby 2.0+, and we still want to support Ruby 1.9.

Furthermore, the *_without_bootstrap aliases that alias_method_chain creates are genuinely useful for users of bootstrap_form, because there are some cases where you don't want the Bootstrap-specific markup.

Essentially, we want the traditional alias_method_chain behavior, but without the pesky deprecation warnings. This commit reimplements alias_method_chain under a new name, bootstrap_method_alias. This allows us to keep the behavior the same and avoid the deprecation warnings.

Fixes #253.

In Rails 5, `alias_method_chain` is deprecated in favor of `Module.prepend`.
However, `prepend` is only available in Ruby 2.0+, and we still want to support
Ruby 1.9.

Furthermore, the `*_without_bootstrap` aliases that `alias_method_chain` creates
are genuinely useful for users of bootstrap_form, because there are some cases
where you don't want the Bootstrap-specific markup.

Essentially, we want the traditional `alias_method_chain` behavior, but without
the pesky deprecation warnings. This commit reimplements `alias_method_chain`
under a new name, `bootstrap_method_alias`. This allows us to keep the behavior
the same and avoid the deprecation warnings.
@mattbrictson mattbrictson changed the title Fix alias_method_chain deprecation msgs in Rails 5 Fix alias_method_chain deprecation messages in Rails 5 May 21, 2016
@siegy22
Copy link
Contributor

siegy22 commented May 22, 2016

looks great to me 👍

@jocubeit
Copy link

This is a really well thought out fix for the deprecation notices. Well done @mattbrictson! 👍

@koenpunt koenpunt mentioned this pull request Jun 7, 2016
@mattbrictson mattbrictson merged commit 67e846f into bootstrap-ruby:master Jun 24, 2016
@koenpunt
Copy link
Contributor

koenpunt commented Jul 2, 2016

Now that Rails 5 is out, could this be released as a new version?

@em77
Copy link

em77 commented Jul 3, 2016

Until new version is out, Rails 5 users can pull directly from GitHub with this in their Gemfile:
gem 'bootstrap_form', require: 'bootstrap_form', git: 'https://github.com/bootstrap-ruby/rails-bootstrap-forms.git'

@koenpunt
Copy link
Contributor

koenpunt commented Jul 3, 2016

Obviously, but I don't prefer relying on a git repo. Also, gem 'bootstrap_form', github: 'bootstrap-ruby/rails-bootstrap-forms' is sufficient.

@mattbrictson mattbrictson deleted the fix-alias-deprecation branch July 4, 2016 20:24
@mattbrictson
Copy link
Contributor Author

Now that Rails 5 is out, could this be released as a new version?

Done: https://rubygems.org/gems/bootstrap_form/versions/2.4.0

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.

5 participants