mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #28829 from y-yagi/follow_up_128b804
Set to `form_with_generates_remote_forms` only when config is explicitly specified
This commit is contained in:
commit
a6a93f9ed5
2 changed files with 32 additions and 2 deletions
|
@ -19,8 +19,10 @@ module ActionView
|
|||
|
||||
initializer "action_view.form_with_generates_remote_forms" do |app|
|
||||
ActiveSupport.on_load(:action_view) do
|
||||
ActionView::Helpers::FormHelper.form_with_generates_remote_forms =
|
||||
app.config.action_view.delete(:form_with_generates_remote_forms)
|
||||
form_with_generates_remote_forms = app.config.action_view.delete(:form_with_generates_remote_forms)
|
||||
unless form_with_generates_remote_forms.nil?
|
||||
ActionView::Helpers::FormHelper.form_with_generates_remote_forms = form_with_generates_remote_forms
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -725,6 +725,34 @@ module ApplicationTests
|
|||
assert_no_match(/data-remote/, last_response.body)
|
||||
end
|
||||
|
||||
test "form_with generates remote forms by default" do
|
||||
app_file "app/models/post.rb", <<-RUBY
|
||||
class Post
|
||||
include ActiveModel::Model
|
||||
attr_accessor :name
|
||||
end
|
||||
RUBY
|
||||
|
||||
app_file "app/controllers/posts_controller.rb", <<-RUBY
|
||||
class PostsController < ApplicationController
|
||||
def index
|
||||
render inline: "<%= begin; form_with(model: Post.new) {|f| f.text_field(:name)}; rescue => e; e.to_s; end %>"
|
||||
end
|
||||
end
|
||||
RUBY
|
||||
|
||||
add_to_config <<-RUBY
|
||||
routes.prepend do
|
||||
resources :posts
|
||||
end
|
||||
RUBY
|
||||
|
||||
app "development"
|
||||
|
||||
get "/posts"
|
||||
assert_match(/data-remote/, last_response.body)
|
||||
end
|
||||
|
||||
test "default method for update can be changed" do
|
||||
app_file "app/models/post.rb", <<-RUBY
|
||||
class Post
|
||||
|
|
Loading…
Reference in a new issue