Skip to content

Commit

Permalink
ActionView patch for Rails 4.2.1/5.0.0
Browse files Browse the repository at this point in the history
This patch is needed for Rails 4.2.1 and 5.0.0 due to the following
commit history in ActionView::Helpers::Tags:

Rails 4.2:

https://github.com/rails/rails/commits/4-2-stable/actionview/lib/action_
view/helpers/tags/translator.rb

https://github.com/rails/rails/commits/4-2-stable/actionview/lib/action_
view/helpers/tags/placeholderable.rb (and label.rb too).

Rails master:

https://github.com/rails/rails/commits/master/actionview/lib/action_view
/helpers/tags/translator.rb

https://github.com/rails/rails/commits/master/actionview/lib/action_view
/helpers/tags/placeholderable.rb (and label.rb too).

Fixes activerecord-hackery#518.

TODO: Find a better way to solve this. Pull requests welcome!
  • Loading branch information
jonatack committed Mar 20, 2015
1 parent c2b316c commit 746f35e
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions lib/ransack/helpers/form_builder.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,36 @@
require 'action_view'

# This patch is needed since this Rails commit:
# https://github.com/rails/rails/commit/c1a118a
#
# TODO: Find a better way to solve this.
# Monkey-patching, avert your eyes!
# TODO: Find a better way to solve these two issues:
#
module ActionView::Helpers::Tags

# This patch is needed since this Rails commit:
# https://github.com/rails/rails/commit/c1a118a
#
class Base
private
def value(object)
object.send @method_name if object # use send instead of public_send
end
end

# This patch is needed for Rails 4.2.1 and 5.0.0 since these commits:
#
# Rails 4.2:
# https://github.com/rails/rails/commits/4-2-stable/actionview/lib/action_view/helpers/tags/translator.rb
# https://github.com/rails/rails/commits/4-2-stable/actionview/lib/action_view/helpers/tags/placeholderable.rb
#
# Rails master:
# https://github.com/rails/rails/commits/master/actionview/lib/action_view/helpers/tags/translator.rb
# https://github.com/rails/rails/commits/master/actionview/lib/action_view/helpers/tags/placeholderable.rb
#
class Translator
def i18n_default
return '' unless model
["#{model}.#{method_and_value}".to_sym, ""]
end
end
end

RANSACK_FORM_BUILDER = 'RANSACK_FORM_BUILDER'.freeze
Expand Down

0 comments on commit 746f35e

Please sign in to comment.