Module: Super::Compatability
- Defined in:
- lib/super/compatibility.rb
Class Method Summary collapse
-
.errable_fields(field) ⇒ Object
Rails 5.1 and after lets you find field errors using either a string or a symbol.
- .polymorphic_path_container ⇒ Object
- .sanitize_sql_like(query) ⇒ Object
Class Method Details
.errable_fields(field) ⇒ Object
Rails 5.1 and after lets you find field errors using either a string or a symbol.
9 10 11 12 13 14 15 |
# File 'lib/super/compatibility.rb', line 9 def errable_fields(field) if Rails::VERSION::MAJOR == 5 && Rails::VERSION::MINOR == 0 [field.to_s, field.to_sym] else field end end |
.polymorphic_path_container ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/super/compatibility.rb', line 27 def polymorphic_path_container if Rails::VERSION::MAJOR == 5 && Rails::VERSION::MINOR == 0 @polymorphic_path_container ||= begin klass = Class.new do include ActionDispatch::Routing::PolymorphicRoutes def method_missing(method_name) Rails.application.routes.url_helpers.public_send(method_name) end def respond_to_missing?(*args, **kwargs) Rails.application.routes.url_helpers.respond_to?(*args, **kwargs) end end klass.new end else Rails.application.routes.url_helpers end end |
.sanitize_sql_like(query) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/super/compatibility.rb', line 17 def sanitize_sql_like(query) if ActiveRecord::VERSION::MAJOR == 4 ActiveRecord::Base.send(:sanitize_sql_like, query) elsif ActiveRecord::VERSION::MAJOR == 5 && ActiveRecord::VERSION::MINOR <= 1 ActiveRecord::Base.send(:sanitize_sql_like, query) else ActiveRecord::Base.sanitize_sql_like(query) end end |