diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2017-08-03 16:22:58 -0400 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2017-08-03 16:40:18 -0400 |
commit | 422ec4cb78cc9c10af97ddf958d477ce604b4506 (patch) | |
tree | 8244c4144f08116ceba495fd2ca873a25a28c530 /actionview/lib | |
parent | d84a126d25df038f6384eb584af37855552a7a4d (diff) | |
download | rails-422ec4cb78cc9c10af97ddf958d477ce604b4506.tar.gz rails-422ec4cb78cc9c10af97ddf958d477ce604b4506.tar.bz2 rails-422ec4cb78cc9c10af97ddf958d477ce604b4506.zip |
Make sure Action View doesn't break with Active Storage
When Active Storage is not loaded and direct_upload is used on
file_field_tag we should not raise an exception.
Diffstat (limited to 'actionview/lib')
-rw-r--r-- | actionview/lib/action_view/helpers/form_tag_helper.rb | 2 | ||||
-rw-r--r-- | actionview/lib/action_view/test_case.rb | 12 |
2 files changed, 13 insertions, 1 deletions
diff --git a/actionview/lib/action_view/helpers/form_tag_helper.rb b/actionview/lib/action_view/helpers/form_tag_helper.rb index 83b600d871..fd7184f8d3 100644 --- a/actionview/lib/action_view/helpers/form_tag_helper.rb +++ b/actionview/lib/action_view/helpers/form_tag_helper.rb @@ -906,7 +906,7 @@ module ActionView end def convert_direct_upload_option_to_url(options) - options.merge('data-direct-upload-url': options.delete(:direct_upload) ? rails_direct_uploads_url : nil).compact + options.merge('data-direct-upload-url': options.delete(:direct_upload) && respond_to?(:rails_direct_uploads_url) ? rails_direct_uploads_url : nil).compact end end end diff --git a/actionview/lib/action_view/test_case.rb b/actionview/lib/action_view/test_case.rb index efe8c87b9b..6913c31a20 100644 --- a/actionview/lib/action_view/test_case.rb +++ b/actionview/lib/action_view/test_case.rb @@ -281,6 +281,18 @@ module ActionView super end end + + def respond_to_missing?(name, include_private = false) + begin + routes = @controller.respond_to?(:_routes) && @controller._routes + rescue + # Dont call routes, if there is an error on _routes call + end + + routes && + (routes.named_routes.route_defined?(name) || + routes.mounted_helpers.method_defined?(name)) + end end include Behavior |