Skip to content

Instantly share code, notes, and snippets.

@inpego
Created October 18, 2016 12:14
Show Gist options
  • Save inpego/3c7228b2030b62ef35dd4dff6c661773 to your computer and use it in GitHub Desktop.
Save inpego/3c7228b2030b62ef35dd4dff6c661773 to your computer and use it in GitHub Desktop.
# This is a very important monkey patch to make Rails 2.3.18 to work with Ruby 2.x
# If you're thinking to remove it, really, don't, unless you know what you're doing.
# KTHXBYE
if Rails::VERSION::MAJOR == 2 && RUBY_VERSION >= '2.0.0'
module ActiveRecord
module Associations
class AssociationProxy
def send(method, *args)
if proxy_respond_to?(method, true)
super
else
load_target
@target.send(method, *args)
end
end
end
end
end
module I18n
module Backend
module Base
def load_file(filename)
type = File.extname(filename).tr('.', '').downcase
# As a fix added second argument as true to respond_to? method
raise UnknownFileType.new(type, filename) unless respond_to?(:"load_#{type}", true)
data = send(:"load_#{type}", filename) # TODO raise a meaningful exception if this does not yield a Hash
data.each { |locale, d| store_translations(locale, d) }
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment