mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Add form_with_generates_remote_forms
config.
Allows users to not have remote forms by default, since there's more JS harness, e.g. bundling rails-ujs, otherwise. Also don't skip creating defaults file anymore. Sprockets isn't the only new config.
This commit is contained in:
parent
6309b85100
commit
a4c1282854
4 changed files with 7 additions and 5 deletions
|
@ -474,6 +474,8 @@ module ActionView
|
|||
end
|
||||
private :apply_form_for_options!
|
||||
|
||||
mattr_accessor(:form_with_generates_remote_forms) { true }
|
||||
|
||||
# Creates a form tag based on mixing URLs, scopes, or models.
|
||||
#
|
||||
# # Using just a URL:
|
||||
|
@ -1503,7 +1505,7 @@ module ActionView
|
|||
end
|
||||
|
||||
private
|
||||
def html_options_for_form_with(url_for_options = nil, model = nil, html: {}, local: false,
|
||||
def html_options_for_form_with(url_for_options = nil, model = nil, html: {}, local: !form_with_generates_remote_forms,
|
||||
skip_enforcing_utf8: false, **options)
|
||||
html_options = options.slice(:id, :class, :multipart, :method, :data).merge(html)
|
||||
html_options[:method] ||= :patch if model.respond_to?(:persisted?) && model.persisted?
|
||||
|
|
|
@ -403,9 +403,7 @@ module Rails
|
|||
end
|
||||
|
||||
def delete_new_framework_defaults
|
||||
# Sprockets owns the only new default for 5.1: if it's disabled,
|
||||
# we don't want the file.
|
||||
unless options[:update] && !options[:skip_sprockets]
|
||||
unless options[:update]
|
||||
remove_file "config/initializers/new_framework_defaults_5_1.rb"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,6 +5,9 @@
|
|||
# Once upgraded flip defaults one by one to migrate to the new default.
|
||||
#
|
||||
# Read the Guide for Upgrading Ruby on Rails for more info on each option.
|
||||
|
||||
# Make `form_with` generate non-remote forms.
|
||||
Rails.application.config.action_view.form_with_generates_remote_forms = false
|
||||
<%- unless options[:skip_sprockets] -%>
|
||||
|
||||
# Unknown asset fallback will return the path passed in when the given
|
||||
|
|
|
@ -410,7 +410,6 @@ class AppGeneratorTest < Rails::Generators::TestCase
|
|||
assert_no_match(/config\.assets\.js_compressor = :uglifier/, content)
|
||||
assert_no_match(/config\.assets\.css_compressor = :sass/, content)
|
||||
end
|
||||
assert_no_file "config/initializers/new_framework_defaults_5_1.rb"
|
||||
end
|
||||
|
||||
def test_generator_if_skip_yarn_is_given
|
||||
|
|
Loading…
Reference in a new issue