Why do basic forms not work in Rails 6 without binding events to each form?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

Why do basic forms not work in Rails 6 without binding events to each form?

Jason Fleetwood-Boldt
it says here in the docs that for turobolinks that you now have to BIND ALL YOUR AJAX EVENTS  (!?!?) if you want your forms to submit correctly. 

https://guides.rubyonrails.org/working_with_javascript_in_rails.html#remote-elements


"You probably don't want to just sit there with a filled out <form>, though. You probably want to do something upon a successful submission. To do that, bind to the ajax:success event. On failure, use ajax:error. Check it out:"

$(document).ready ->
  $("#new_article").on("ajax:success", (event) ->
    [data, status, xhr] = event.detail
    $("#new_article").append xhr.responseText
  ).on "ajax:error", (event) ->
    $("#new_article").append "<p>ERROR</p>"


basically… sitting there with a filled out form is exactly what happens if you just do a generic form_with and post it now in Rails 6 … literally, the user just sits there and nothing happens.

are you really supposed to bind all your turbolinks forms throughout your website like this? This seems totally nuts to me, and, kind of, not at all 'unobtrusive' … (I thought the whole point of 'unobtrusive' was to not have to write a lot of helper/glue/boiler plate code.)

it seems totally crazy to me that out-of-the-box Rails 6 installations can't do the most basic web function of submitting a form without the developer having to know about binding events of the Ajax calls. In the old days didn't this used to 'just work' out of the box?

anyone else have any thoughts on this and think Rails is moving in the wrong direction here? The main attraction of Rais is how easy it is to make so much functionality with little config and effort, and this area seems too basic to me to require this top-heavy approach that requires binding up Ajax events.

I think Rails 7 should move away from having turbolinks turned on by default — it's a good technology if you want to opt-in to it, but it's got so much configuration that it often just gets in the way for new Rails apps. It would be very easy to simply leave off Turbolinks in default Rails apps and then simply provide instructions for opting-in to it. (Like, active record session store and other things that used to be default and then were extracted out into separate opt-in gems.) 


Thoughts?

Jason





--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/511637f0-dec3-4bd1-9648-a823c140669b%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Why do basic forms not work in Rails 6 without binding events to each form?

Ariel Juodziukynas
It doesn't say you that you HAVE to bind all the ajax events. It explicitly says that you "probably" want to do that if you "probably" want to do something other than just submitting the form.

El dom., 16 feb. 2020 a las 17:53, Momeas Interactive (<[hidden email]>) escribió:
it says here in the docs that for turobolinks that you now have to BIND ALL YOUR AJAX EVENTS  (!?!?) if you want your forms to submit correctly. 



"You probably don't want to just sit there with a filled out <form>, though. You probably want to do something upon a successful submission. To do that, bind to the ajax:success event. On failure, use ajax:error. Check it out:"

$(document).ready ->
  $("#new_article").on("ajax:success", (event) ->
    [data, status, xhr] = event.detail
    $("#new_article").append xhr.responseText
  ).on "ajax:error", (event) ->
    $("#new_article").append "<p>ERROR</p>"


basically… sitting there with a filled out form is exactly what happens if you just do a generic form_with and post it now in Rails 6 … literally, the user just sits there and nothing happens.

are you really supposed to bind all your turbolinks forms throughout your website like this? This seems totally nuts to me, and, kind of, not at all 'unobtrusive' … (I thought the whole point of 'unobtrusive' was to not have to write a lot of helper/glue/boiler plate code.)

it seems totally crazy to me that out-of-the-box Rails 6 installations can't do the most basic web function of submitting a form without the developer having to know about binding events of the Ajax calls. In the old days didn't this used to 'just work' out of the box?

anyone else have any thoughts on this and think Rails is moving in the wrong direction here? The main attraction of Rais is how easy it is to make so much functionality with little config and effort, and this area seems too basic to me to require this top-heavy approach that requires binding up Ajax events.

I think Rails 7 should move away from having turbolinks turned on by default — it's a good technology if you want to opt-in to it, but it's got so much configuration that it often just gets in the way for new Rails apps. It would be very easy to simply leave off Turbolinks in default Rails apps and then simply provide instructions for opting-in to it. (Like, active record session store and other things that used to be default and then were extracted out into separate opt-in gems.) 


Thoughts?

Jason





--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/511637f0-dec3-4bd1-9648-a823c140669b%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAPS3bcA%2BWbyWwg%2BpWgerkaLA5QmxofgfXUN-Nv1krTyYuoWjjg%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Why do basic forms not work in Rails 6 without binding events to each form?

Jason Fleetwood-Boldt
Incorrect. You HAVE to bind your Ajax events, or else there is no functionality. (the page does not refresh and gives no user interaction). I do not think that expecting user interaction is an abnormal expectation in a modern web app.



On Sunday, February 16, 2020 at 5:39:20 PM UTC-5, Ariel Juodziukynas wrote:
It doesn't say you that you HAVE to bind all the ajax events. It explicitly says that you "probably" want to do that if you "probably" want to do something other than just submitting the form.

El dom., 16 feb. 2020 a las 17:53, Momeas Interactive (<<a href="javascript:" target="_blank" gdf-obfuscated-mailto="6DLRRfDSBAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">te...@...>) escribió:
it says here in the docs that for turobolinks that you now have to BIND ALL YOUR AJAX EVENTS  (!?!?) if you want your forms to submit correctly. 

<a href="https://guides.rubyonrails.org/working_with_javascript_in_rails.html#remote-elements" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fguides.rubyonrails.org%2Fworking_with_javascript_in_rails.html%23remote-elements\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEeZ-6D3LtBjJ1JCJEAZYsuVkTZtg&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fguides.rubyonrails.org%2Fworking_with_javascript_in_rails.html%23remote-elements\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEeZ-6D3LtBjJ1JCJEAZYsuVkTZtg&#39;;return true;">https://guides.rubyonrails.org/working_with_javascript_in_rails.html#remote-elements


"You probably don't want to just sit there with a filled out <form>, though. You probably want to do something upon a successful submission. To do that, bind to the ajax:success event. On failure, use ajax:error. Check it out:"

$(document).ready ->
  $("#new_article").on("ajax:success", (event) ->
    [data, status, xhr] = event.detail
    $("#new_article").append xhr.responseText
  ).on "ajax:error", (event) ->
    $("#new_article").append "<p>ERROR</p>"


basically… sitting there with a filled out form is exactly what happens if you just do a generic form_with and post it now in Rails 6 … literally, the user just sits there and nothing happens.

are you really supposed to bind all your turbolinks forms throughout your website like this? This seems totally nuts to me, and, kind of, not at all 'unobtrusive' … (I thought the whole point of 'unobtrusive' was to not have to write a lot of helper/glue/boiler plate code.)

it seems totally crazy to me that out-of-the-box Rails 6 installations can't do the most basic web function of submitting a form without the developer having to know about binding events of the Ajax calls. In the old days didn't this used to 'just work' out of the box?

anyone else have any thoughts on this and think Rails is moving in the wrong direction here? The main attraction of Rais is how easy it is to make so much functionality with little config and effort, and this area seems too basic to me to require this top-heavy approach that requires binding up Ajax events.

I think Rails 7 should move away from having turbolinks turned on by default — it's a good technology if you want to opt-in to it, but it's got so much configuration that it often just gets in the way for new Rails apps. It would be very easy to simply leave off Turbolinks in default Rails apps and then simply provide instructions for opting-in to it. (Like, active record session store and other things that used to be default and then were extracted out into separate opt-in gems.) 


Thoughts?

Jason





--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="6DLRRfDSBAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">rubyonra...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/rubyonrails-talk/511637f0-dec3-4bd1-9648-a823c140669b%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/rubyonrails-talk/511637f0-dec3-4bd1-9648-a823c140669b%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/rubyonrails-talk/511637f0-dec3-4bd1-9648-a823c140669b%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/rubyonrails-talk/511637f0-dec3-4bd1-9648-a823c140669b%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/39ae14f7-72e1-48c3-9d44-371a4e9a799f%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Why do basic forms not work in Rails 6 without binding events to each form?

Ariel Juodziukynas
I have a few rails 6 projects and remote forms works out of the box with no event binding. Can you reproduce that problem with a clean rails app? maybe you have some other js messing up rails' ajax handers.

El mar., 18 feb. 2020 a las 14:22, Momeas Interactive (<[hidden email]>) escribió:
Incorrect. You HAVE to bind your Ajax events, or else there is no functionality. (the page does not refresh and gives no user interaction). I do not think that expecting user interaction is an abnormal expectation in a modern web app.



On Sunday, February 16, 2020 at 5:39:20 PM UTC-5, Ariel Juodziukynas wrote:
It doesn't say you that you HAVE to bind all the ajax events. It explicitly says that you "probably" want to do that if you "probably" want to do something other than just submitting the form.

El dom., 16 feb. 2020 a las 17:53, Momeas Interactive (<[hidden email]>) escribió:
it says here in the docs that for turobolinks that you now have to BIND ALL YOUR AJAX EVENTS  (!?!?) if you want your forms to submit correctly. 



"You probably don't want to just sit there with a filled out <form>, though. You probably want to do something upon a successful submission. To do that, bind to the ajax:success event. On failure, use ajax:error. Check it out:"

$(document).ready ->
  $("#new_article").on("ajax:success", (event) ->
    [data, status, xhr] = event.detail
    $("#new_article").append xhr.responseText
  ).on "ajax:error", (event) ->
    $("#new_article").append "<p>ERROR</p>"


basically… sitting there with a filled out form is exactly what happens if you just do a generic form_with and post it now in Rails 6 … literally, the user just sits there and nothing happens.

are you really supposed to bind all your turbolinks forms throughout your website like this? This seems totally nuts to me, and, kind of, not at all 'unobtrusive' … (I thought the whole point of 'unobtrusive' was to not have to write a lot of helper/glue/boiler plate code.)

it seems totally crazy to me that out-of-the-box Rails 6 installations can't do the most basic web function of submitting a form without the developer having to know about binding events of the Ajax calls. In the old days didn't this used to 'just work' out of the box?

anyone else have any thoughts on this and think Rails is moving in the wrong direction here? The main attraction of Rais is how easy it is to make so much functionality with little config and effort, and this area seems too basic to me to require this top-heavy approach that requires binding up Ajax events.

I think Rails 7 should move away from having turbolinks turned on by default — it's a good technology if you want to opt-in to it, but it's got so much configuration that it often just gets in the way for new Rails apps. It would be very easy to simply leave off Turbolinks in default Rails apps and then simply provide instructions for opting-in to it. (Like, active record session store and other things that used to be default and then were extracted out into separate opt-in gems.) 


Thoughts?

Jason





--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/511637f0-dec3-4bd1-9648-a823c140669b%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/39ae14f7-72e1-48c3-9d44-371a4e9a799f%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAPS3bcD3pz32uZN%3DPMOBRkM%3DdRr%2BGqCxS5o5zV9ChUQLdzpDyA%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Why do basic forms not work in Rails 6 without binding events to each form?

Ariel Juodziukynas
Can you share some code to reproduce the problem? (a github repo with a simple rais app would be greate)

El mar., 18 feb. 2020 a las 14:24, Ariel Juodziukynas (<[hidden email]>) escribió:
I have a few rails 6 projects and remote forms works out of the box with no event binding. Can you reproduce that problem with a clean rails app? maybe you have some other js messing up rails' ajax handers.

El mar., 18 feb. 2020 a las 14:22, Momeas Interactive (<[hidden email]>) escribió:
Incorrect. You HAVE to bind your Ajax events, or else there is no functionality. (the page does not refresh and gives no user interaction). I do not think that expecting user interaction is an abnormal expectation in a modern web app.



On Sunday, February 16, 2020 at 5:39:20 PM UTC-5, Ariel Juodziukynas wrote:
It doesn't say you that you HAVE to bind all the ajax events. It explicitly says that you "probably" want to do that if you "probably" want to do something other than just submitting the form.

El dom., 16 feb. 2020 a las 17:53, Momeas Interactive (<[hidden email]>) escribió:
it says here in the docs that for turobolinks that you now have to BIND ALL YOUR AJAX EVENTS  (!?!?) if you want your forms to submit correctly. 



"You probably don't want to just sit there with a filled out <form>, though. You probably want to do something upon a successful submission. To do that, bind to the ajax:success event. On failure, use ajax:error. Check it out:"

$(document).ready ->
  $("#new_article").on("ajax:success", (event) ->
    [data, status, xhr] = event.detail
    $("#new_article").append xhr.responseText
  ).on "ajax:error", (event) ->
    $("#new_article").append "<p>ERROR</p>"


basically… sitting there with a filled out form is exactly what happens if you just do a generic form_with and post it now in Rails 6 … literally, the user just sits there and nothing happens.

are you really supposed to bind all your turbolinks forms throughout your website like this? This seems totally nuts to me, and, kind of, not at all 'unobtrusive' … (I thought the whole point of 'unobtrusive' was to not have to write a lot of helper/glue/boiler plate code.)

it seems totally crazy to me that out-of-the-box Rails 6 installations can't do the most basic web function of submitting a form without the developer having to know about binding events of the Ajax calls. In the old days didn't this used to 'just work' out of the box?

anyone else have any thoughts on this and think Rails is moving in the wrong direction here? The main attraction of Rais is how easy it is to make so much functionality with little config and effort, and this area seems too basic to me to require this top-heavy approach that requires binding up Ajax events.

I think Rails 7 should move away from having turbolinks turned on by default — it's a good technology if you want to opt-in to it, but it's got so much configuration that it often just gets in the way for new Rails apps. It would be very easy to simply leave off Turbolinks in default Rails apps and then simply provide instructions for opting-in to it. (Like, active record session store and other things that used to be default and then were extracted out into separate opt-in gems.) 


Thoughts?

Jason





--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/511637f0-dec3-4bd1-9648-a823c140669b%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/39ae14f7-72e1-48c3-9d44-371a4e9a799f%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAPS3bcCEYS-AwxtUsgmHGK4AnRWeCGdyzoTq_4rjwxiCP52JYA%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Why do basic forms not work in Rails 6 without binding events to each form?

Ariel Juodziukynas
And also (sorry for the multiple responses), you are showing jquery code, rails moved out of jquery a long time ago (I think docs are outdated though), something might be wrong with your setup.

El mar., 18 feb. 2020 a las 14:25, Ariel Juodziukynas (<[hidden email]>) escribió:
Can you share some code to reproduce the problem? (a github repo with a simple rais app would be greate)

El mar., 18 feb. 2020 a las 14:24, Ariel Juodziukynas (<[hidden email]>) escribió:
I have a few rails 6 projects and remote forms works out of the box with no event binding. Can you reproduce that problem with a clean rails app? maybe you have some other js messing up rails' ajax handers.

El mar., 18 feb. 2020 a las 14:22, Momeas Interactive (<[hidden email]>) escribió:
Incorrect. You HAVE to bind your Ajax events, or else there is no functionality. (the page does not refresh and gives no user interaction). I do not think that expecting user interaction is an abnormal expectation in a modern web app.



On Sunday, February 16, 2020 at 5:39:20 PM UTC-5, Ariel Juodziukynas wrote:
It doesn't say you that you HAVE to bind all the ajax events. It explicitly says that you "probably" want to do that if you "probably" want to do something other than just submitting the form.

El dom., 16 feb. 2020 a las 17:53, Momeas Interactive (<[hidden email]>) escribió:
it says here in the docs that for turobolinks that you now have to BIND ALL YOUR AJAX EVENTS  (!?!?) if you want your forms to submit correctly. 



"You probably don't want to just sit there with a filled out <form>, though. You probably want to do something upon a successful submission. To do that, bind to the ajax:success event. On failure, use ajax:error. Check it out:"

$(document).ready ->
  $("#new_article").on("ajax:success", (event) ->
    [data, status, xhr] = event.detail
    $("#new_article").append xhr.responseText
  ).on "ajax:error", (event) ->
    $("#new_article").append "<p>ERROR</p>"


basically… sitting there with a filled out form is exactly what happens if you just do a generic form_with and post it now in Rails 6 … literally, the user just sits there and nothing happens.

are you really supposed to bind all your turbolinks forms throughout your website like this? This seems totally nuts to me, and, kind of, not at all 'unobtrusive' … (I thought the whole point of 'unobtrusive' was to not have to write a lot of helper/glue/boiler plate code.)

it seems totally crazy to me that out-of-the-box Rails 6 installations can't do the most basic web function of submitting a form without the developer having to know about binding events of the Ajax calls. In the old days didn't this used to 'just work' out of the box?

anyone else have any thoughts on this and think Rails is moving in the wrong direction here? The main attraction of Rais is how easy it is to make so much functionality with little config and effort, and this area seems too basic to me to require this top-heavy approach that requires binding up Ajax events.

I think Rails 7 should move away from having turbolinks turned on by default — it's a good technology if you want to opt-in to it, but it's got so much configuration that it often just gets in the way for new Rails apps. It would be very easy to simply leave off Turbolinks in default Rails apps and then simply provide instructions for opting-in to it. (Like, active record session store and other things that used to be default and then were extracted out into separate opt-in gems.) 


Thoughts?

Jason





--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/511637f0-dec3-4bd1-9648-a823c140669b%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/39ae14f7-72e1-48c3-9d44-371a4e9a799f%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAPS3bcCqkdreg8hRWZbm9eyg4Oa0379P4EdCWVO1BtAA%2BDR8Yg%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Why do basic forms not work in Rails 6 without binding events to each form?

Jason Fleetwood-Boldt

Yes, I was discussing this in the Slack channel yesterday in the #coding room

You're right that Rails no longer installs JQUery by default, but lots of things just go ahead and encourage it anyway. (which Is fine and not what I'm complaining about)


This guide, for example, as I said above, encourages you to use jQUery to add Ajax events to your form submit:


You could of course not use jQuery and do it another way, except that rails-ujs, which is really the problem here, expect you not to.

Right at the top of the https://github.com/rails/jquery-ujs/wiki/ajax docs it says that the UJS events are emitted through jQuery.

So I realize that UJS is also at play here, and neither UJS nor jQUery are my complaints. 

My complaint is that this obscure non-intuitive part of Rails is required to do something basic-- like submit a form-- and that Rails 6 has too much configuration over convention. 

These days when I install Rails 6 all I do is configuration, configuration, configuration (and fighting with these obscure parts of Rails to configure it some more) 
my code just looks like this:


- if @unsubscribe
  = form_with url: '/unsubscribe' do |f|
    = f.hidden_field :email, value: @unsubscribe.email
    = f.hidden_field :nonce, value: @unsubscribe.nonce

    You are confirming that you want to unsubscribe:
    %br
    %br
    = f.text_field :email, disabled: true, value: @unsubscribe.email
    %br
    %br
    = f.submit 'Unsubscribe'


When I do this, the form is submitted as Javascript (JS). if I add local: true then the form is submitted as HTML. 

This is not a bug, it is a complaint. 

the default behavior (to submit using JS) shouldn't leave my app in a non-working buggy state (nothing happens unless you bind an event to the Ajax event). that's the complaint. 

-Jason





On Tuesday, February 18, 2020 at 12:27:26 PM UTC-5, Ariel Juodziukynas wrote:
And also (sorry for the multiple responses), you are showing jquery code, rails moved out of jquery a long time ago (I think docs are outdated though), something might be wrong with your setup.

El mar., 18 feb. 2020 a las 14:25, Ariel Juodziukynas (<<a href="javascript:" target="_blank" gdf-obfuscated-mailto="A-h7NBRfBQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">arie...@...>) escribió:
Can you share some code to reproduce the problem? (a github repo with a simple rais app would be greate)

El mar., 18 feb. 2020 a las 14:24, Ariel Juodziukynas (<<a href="javascript:" target="_blank" gdf-obfuscated-mailto="A-h7NBRfBQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">arie...@...>) escribió:
I have a few rails 6 projects and remote forms works out of the box with no event binding. Can you reproduce that problem with a clean rails app? maybe you have some other js messing up rails' ajax handers.

El mar., 18 feb. 2020 a las 14:22, Momeas Interactive (<<a href="javascript:" target="_blank" gdf-obfuscated-mailto="A-h7NBRfBQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">te...@...>) escribió:
Incorrect. You HAVE to bind your Ajax events, or else there is no functionality. (the page does not refresh and gives no user interaction). I do not think that expecting user interaction is an abnormal expectation in a modern web app.



On Sunday, February 16, 2020 at 5:39:20 PM UTC-5, Ariel Juodziukynas wrote:
It doesn't say you that you HAVE to bind all the ajax events. It explicitly says that you "probably" want to do that if you "probably" want to do something other than just submitting the form.

El dom., 16 feb. 2020 a las 17:53, Momeas Interactive (<[hidden email]>) escribió:
it says here in the docs that for turobolinks that you now have to BIND ALL YOUR AJAX EVENTS  (!?!?) if you want your forms to submit correctly. 

<a href="https://guides.rubyonrails.org/working_with_javascript_in_rails.html#remote-elements" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fguides.rubyonrails.org%2Fworking_with_javascript_in_rails.html%23remote-elements\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEeZ-6D3LtBjJ1JCJEAZYsuVkTZtg&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fguides.rubyonrails.org%2Fworking_with_javascript_in_rails.html%23remote-elements\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEeZ-6D3LtBjJ1JCJEAZYsuVkTZtg&#39;;return true;">https://guides.rubyonrails.org/working_with_javascript_in_rails.html#remote-elements


"You probably don't want to just sit there with a filled out <form>, though. You probably want to do something upon a successful submission. To do that, bind to the ajax:success event. On failure, use ajax:error. Check it out:"

$(document).ready ->
  $("#new_article").on("ajax:success", (event) ->
    [data, status, xhr] = event.detail
    $("#new_article").append xhr.responseText
  ).on "ajax:error", (event) ->
    $("#new_article").append "<p>ERROR</p>"


basically… sitting there with a filled out form is exactly what happens if you just do a generic form_with and post it now in Rails 6 … literally, the user just sits there and nothing happens.

are you really supposed to bind all your turbolinks forms throughout your website like this? This seems totally nuts to me, and, kind of, not at all 'unobtrusive' … (I thought the whole point of 'unobtrusive' was to not have to write a lot of helper/glue/boiler plate code.)

it seems totally crazy to me that out-of-the-box Rails 6 installations can't do the most basic web function of submitting a form without the developer having to know about binding events of the Ajax calls. In the old days didn't this used to 'just work' out of the box?

anyone else have any thoughts on this and think Rails is moving in the wrong direction here? The main attraction of Rais is how easy it is to make so much functionality with little config and effort, and this area seems too basic to me to require this top-heavy approach that requires binding up Ajax events.

I think Rails 7 should move away from having turbolinks turned on by default — it's a good technology if you want to opt-in to it, but it's got so much configuration that it often just gets in the way for new Rails apps. It would be very easy to simply leave off Turbolinks in default Rails apps and then simply provide instructions for opting-in to it. (Like, active record session store and other things that used to be default and then were extracted out into separate opt-in gems.) 


Thoughts?

Jason





--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/rubyonrails-talk/511637f0-dec3-4bd1-9648-a823c140669b%40googlegroups.com?utm_medium=email&amp;utm_source=footer" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/rubyonrails-talk/511637f0-dec3-4bd1-9648-a823c140669b%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/rubyonrails-talk/511637f0-dec3-4bd1-9648-a823c140669b%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/rubyonrails-talk/511637f0-dec3-4bd1-9648-a823c140669b%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="A-h7NBRfBQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">rubyonra...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/rubyonrails-talk/39ae14f7-72e1-48c3-9d44-371a4e9a799f%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/rubyonrails-talk/39ae14f7-72e1-48c3-9d44-371a4e9a799f%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/rubyonrails-talk/39ae14f7-72e1-48c3-9d44-371a4e9a799f%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/rubyonrails-talk/39ae14f7-72e1-48c3-9d44-371a4e9a799f%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/9021a944-10e2-4320-9c2f-b5b68743fb8e%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Why do basic forms not work in Rails 6 without binding events to each form?

Ariel Juodziukynas
I understand your complain, what I'm saying is that I have some rails 6 projects using form_for remote and form_with and I didn't have to bind to the ajax events. rails-ujs and jquery_ujs both expect you to render a view with .js format and both libraries executes your response's javascript.

Are you rendering a js view when you process the unsubscribe action? what does you action do? what do you respond to the user from your server? you have to tell rails what to do when you submit the form, how are you telling rails what to do?

El mar., 18 feb. 2020 a las 14:46, Momeas Interactive (<[hidden email]>) escribió:

Yes, I was discussing this in the Slack channel yesterday in the #coding room

You're right that Rails no longer installs JQUery by default, but lots of things just go ahead and encourage it anyway. (which Is fine and not what I'm complaining about)


This guide, for example, as I said above, encourages you to use jQUery to add Ajax events to your form submit:


You could of course not use jQuery and do it another way, except that rails-ujs, which is really the problem here, expect you not to.

Right at the top of the https://github.com/rails/jquery-ujs/wiki/ajax docs it says that the UJS events are emitted through jQuery.

So I realize that UJS is also at play here, and neither UJS nor jQUery are my complaints. 

My complaint is that this obscure non-intuitive part of Rails is required to do something basic-- like submit a form-- and that Rails 6 has too much configuration over convention. 

These days when I install Rails 6 all I do is configuration, configuration, configuration (and fighting with these obscure parts of Rails to configure it some more) 
my code just looks like this:


- if @unsubscribe
  = form_with url: '/unsubscribe' do |f|
    = f.hidden_field :email, value: @unsubscribe.email
    = f.hidden_field :nonce, value: @unsubscribe.nonce

    You are confirming that you want to unsubscribe:
    %br
    %br
    = f.text_field :email, disabled: true, value: @unsubscribe.email
    %br
    %br
    = f.submit 'Unsubscribe'


When I do this, the form is submitted as Javascript (JS). if I add local: true then the form is submitted as HTML. 

This is not a bug, it is a complaint. 

the default behavior (to submit using JS) shouldn't leave my app in a non-working buggy state (nothing happens unless you bind an event to the Ajax event). that's the complaint. 

-Jason





On Tuesday, February 18, 2020 at 12:27:26 PM UTC-5, Ariel Juodziukynas wrote:
And also (sorry for the multiple responses), you are showing jquery code, rails moved out of jquery a long time ago (I think docs are outdated though), something might be wrong with your setup.

El mar., 18 feb. 2020 a las 14:25, Ariel Juodziukynas (<[hidden email]>) escribió:
Can you share some code to reproduce the problem? (a github repo with a simple rais app would be greate)

El mar., 18 feb. 2020 a las 14:24, Ariel Juodziukynas (<[hidden email]>) escribió:
I have a few rails 6 projects and remote forms works out of the box with no event binding. Can you reproduce that problem with a clean rails app? maybe you have some other js messing up rails' ajax handers.

El mar., 18 feb. 2020 a las 14:22, Momeas Interactive (<[hidden email]>) escribió:
Incorrect. You HAVE to bind your Ajax events, or else there is no functionality. (the page does not refresh and gives no user interaction). I do not think that expecting user interaction is an abnormal expectation in a modern web app.



On Sunday, February 16, 2020 at 5:39:20 PM UTC-5, Ariel Juodziukynas wrote:
It doesn't say you that you HAVE to bind all the ajax events. It explicitly says that you "probably" want to do that if you "probably" want to do something other than just submitting the form.

El dom., 16 feb. 2020 a las 17:53, Momeas Interactive (<[hidden email]>) escribió:
it says here in the docs that for turobolinks that you now have to BIND ALL YOUR AJAX EVENTS  (!?!?) if you want your forms to submit correctly. 



"You probably don't want to just sit there with a filled out <form>, though. You probably want to do something upon a successful submission. To do that, bind to the ajax:success event. On failure, use ajax:error. Check it out:"

$(document).ready ->
  $("#new_article").on("ajax:success", (event) ->
    [data, status, xhr] = event.detail
    $("#new_article").append xhr.responseText
  ).on "ajax:error", (event) ->
    $("#new_article").append "<p>ERROR</p>"


basically… sitting there with a filled out form is exactly what happens if you just do a generic form_with and post it now in Rails 6 … literally, the user just sits there and nothing happens.

are you really supposed to bind all your turbolinks forms throughout your website like this? This seems totally nuts to me, and, kind of, not at all 'unobtrusive' … (I thought the whole point of 'unobtrusive' was to not have to write a lot of helper/glue/boiler plate code.)

it seems totally crazy to me that out-of-the-box Rails 6 installations can't do the most basic web function of submitting a form without the developer having to know about binding events of the Ajax calls. In the old days didn't this used to 'just work' out of the box?

anyone else have any thoughts on this and think Rails is moving in the wrong direction here? The main attraction of Rais is how easy it is to make so much functionality with little config and effort, and this area seems too basic to me to require this top-heavy approach that requires binding up Ajax events.

I think Rails 7 should move away from having turbolinks turned on by default — it's a good technology if you want to opt-in to it, but it's got so much configuration that it often just gets in the way for new Rails apps. It would be very easy to simply leave off Turbolinks in default Rails apps and then simply provide instructions for opting-in to it. (Like, active record session store and other things that used to be default and then were extracted out into separate opt-in gems.) 


Thoughts?

Jason





--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/511637f0-dec3-4bd1-9648-a823c140669b%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/39ae14f7-72e1-48c3-9d44-371a4e9a799f%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/9021a944-10e2-4320-9c2f-b5b68743fb8e%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAPS3bcDGVMXcqquFt15RkjCjPrSqzUgNgk9nP65RDc0zX4GKwA%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Why do basic forms not work in Rails 6 without binding events to each form?

San Ji
In reply to this post by Jason Fleetwood-Boldt
I don't think you can blame Rails 6 for that. It is a weird default, but it is like that from the very beginning.
I never use the method, so, I guess, it can be considered as somewhat obscure. It seems to appear in Rails version 5.1 and no change since.
Normally, I would use ActiveModel for a local form. Just in case you don't know, ActiveModel can also be used independently from ActiveRecord.

This is the earliest docs I found.
https://api.rubyonrails.org/v5.1/classes/ActionView/Helpers/FormHelper.html#method-i-form_with

Guess someone already complained, but it is too late; there is no good reason to introduces breaking changes for a better default.
Also, in a sense, this can be the better default, since ActiveModel is there for you to build a form for the same app.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/3e340425-4707-456e-9f3c-4a1a6fa09bc8%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Why do basic forms not work in Rails 6 without binding events to each form?

Jason Fleetwood-Boldt
In reply to this post by Ariel Juodziukynas
Let me try again on a new Rails app and confirm that I am right.… if what YOU say is correct then I missed something when debugging and it is my bad. 
Will revert on this

On Tuesday, February 18, 2020 at 1:41:02 PM UTC-5, Ariel Juodziukynas wrote:
I understand your complain, what I'm saying is that I have some rails 6 projects using form_for remote and form_with and I didn't have to bind to the ajax events. rails-ujs and jquery_ujs both expect you to render a view with .js format and both libraries executes your response's javascript.

Are you rendering a js view when you process the unsubscribe action? what does you action do? what do you respond to the user from your server? you have to tell rails what to do when you submit the form, how are you telling rails what to do?

El mar., 18 feb. 2020 a las 14:46, Momeas Interactive (<<a href="javascript:" target="_blank" gdf-obfuscated-mailto="CufZlxhjBQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">te...@...>) escribió:

Yes, I was discussing this in the Slack channel yesterday in the #coding room

You're right that Rails no longer installs JQUery by default, but lots of things just go ahead and encourage it anyway. (which Is fine and not what I'm complaining about)


This guide, for example, as I said above, encourages you to use jQUery to add Ajax events to your form submit:

<a href="https://guides.rubyonrails.org/working_with_javascript_in_rails.html#remote-elements" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fguides.rubyonrails.org%2Fworking_with_javascript_in_rails.html%23remote-elements\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEeZ-6D3LtBjJ1JCJEAZYsuVkTZtg&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fguides.rubyonrails.org%2Fworking_with_javascript_in_rails.html%23remote-elements\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEeZ-6D3LtBjJ1JCJEAZYsuVkTZtg&#39;;return true;">https://guides.rubyonrails.org/working_with_javascript_in_rails.html#remote-elements

You could of course not use jQuery and do it another way, except that rails-ujs, which is really the problem here, expect you not to.

Right at the top of the <a href="https://github.com/rails/jquery-ujs/wiki/ajax" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Frails%2Fjquery-ujs%2Fwiki%2Fajax\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEyGRJUbBLcWmb7kaG27SPc5nphMA&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Frails%2Fjquery-ujs%2Fwiki%2Fajax\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEyGRJUbBLcWmb7kaG27SPc5nphMA&#39;;return true;">https://github.com/rails/jquery-ujs/wiki/ajax docs it says that the UJS events are emitted through jQuery.

So I realize that UJS is also at play here, and neither UJS nor jQUery are my complaints. 

My complaint is that this obscure non-intuitive part of Rails is required to do something basic-- like submit a form-- and that Rails 6 has too much configuration over convention. 

These days when I install Rails 6 all I do is configuration, configuration, configuration (and fighting with these obscure parts of Rails to configure it some more) 
my code just looks like this:


- if @unsubscribe
  = form_with url: '/unsubscribe' do |f|
    = f.hidden_field :email, value: @unsubscribe.email
    = f.hidden_field :nonce, value: @unsubscribe.nonce

    You are confirming that you want to unsubscribe:
    %br
    %br
    = f.text_field :email, disabled: true, value: @unsubscribe.email
    %br
    %br
    = f.submit 'Unsubscribe'


When I do this, the form is submitted as Javascript (JS). if I add local: true then the form is submitted as HTML. 

This is not a bug, it is a complaint. 

the default behavior (to submit using JS) shouldn't leave my app in a non-working buggy state (nothing happens unless you bind an event to the Ajax event). that's the complaint. 

-Jason





On Tuesday, February 18, 2020 at 12:27:26 PM UTC-5, Ariel Juodziukynas wrote:
And also (sorry for the multiple responses), you are showing jquery code, rails moved out of jquery a long time ago (I think docs are outdated though), something might be wrong with your setup.

El mar., 18 feb. 2020 a las 14:25, Ariel Juodziukynas (<[hidden email]>) escribió:
Can you share some code to reproduce the problem? (a github repo with a simple rais app would be greate)

El mar., 18 feb. 2020 a las 14:24, Ariel Juodziukynas (<[hidden email]>) escribió:
I have a few rails 6 projects and remote forms works out of the box with no event binding. Can you reproduce that problem with a clean rails app? maybe you have some other js messing up rails' ajax handers.

El mar., 18 feb. 2020 a las 14:22, Momeas Interactive (<[hidden email]>) escribió:
Incorrect. You HAVE to bind your Ajax events, or else there is no functionality. (the page does not refresh and gives no user interaction). I do not think that expecting user interaction is an abnormal expectation in a modern web app.



On Sunday, February 16, 2020 at 5:39:20 PM UTC-5, Ariel Juodziukynas wrote:
It doesn't say you that you HAVE to bind all the ajax events. It explicitly says that you "probably" want to do that if you "probably" want to do something other than just submitting the form.

El dom., 16 feb. 2020 a las 17:53, Momeas Interactive (<[hidden email]>) escribió:
it says here in the docs that for turobolinks that you now have to BIND ALL YOUR AJAX EVENTS  (!?!?) if you want your forms to submit correctly. 

<a href="https://guides.rubyonrails.org/working_with_javascript_in_rails.html#remote-elements" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fguides.rubyonrails.org%2Fworking_with_javascript_in_rails.html%23remote-elements\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEeZ-6D3LtBjJ1JCJEAZYsuVkTZtg&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fguides.rubyonrails.org%2Fworking_with_javascript_in_rails.html%23remote-elements\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEeZ-6D3LtBjJ1JCJEAZYsuVkTZtg&#39;;return true;">https://guides.rubyonrails.org/working_with_javascript_in_rails.html#remote-elements


"You probably don't want to just sit there with a filled out <form>, though. You probably want to do something upon a successful submission. To do that, bind to the ajax:success event. On failure, use ajax:error. Check it out:"

$(document).ready ->
  $("#new_article").on("ajax:success", (event) ->
    [data, status, xhr] = event.detail
    $("#new_article").append xhr.responseText
  ).on "ajax:error", (event) ->
    $("#new_article").append "<p>ERROR</p>"


basically… sitting there with a filled out form is exactly what happens if you just do a generic form_with and post it now in Rails 6 … literally, the user just sits there and nothing happens.

are you really supposed to bind all your turbolinks forms throughout your website like this? This seems totally nuts to me, and, kind of, not at all 'unobtrusive' … (I thought the whole point of 'unobtrusive' was to not have to write a lot of helper/glue/boiler plate code.)

it seems totally crazy to me that out-of-the-box Rails 6 installations can't do the most basic web function of submitting a form without the developer having to know about binding events of the Ajax calls. In the old days didn't this used to 'just work' out of the box?

anyone else have any thoughts on this and think Rails is moving in the wrong direction here? The main attraction of Rais is how easy it is to make so much functionality with little config and effort, and this area seems too basic to me to require this top-heavy approach that requires binding up Ajax events.

I think Rails 7 should move away from having turbolinks turned on by default — it's a good technology if you want to opt-in to it, but it's got so much configuration that it often just gets in the way for new Rails apps. It would be very easy to simply leave off Turbolinks in default Rails apps and then simply provide instructions for opting-in to it. (Like, active record session store and other things that used to be default and then were extracted out into separate opt-in gems.) 


Thoughts?

Jason





--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/rubyonrails-talk/511637f0-dec3-4bd1-9648-a823c140669b%40googlegroups.com?utm_medium=email&amp;utm_source=footer" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/rubyonrails-talk/511637f0-dec3-4bd1-9648-a823c140669b%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/rubyonrails-talk/511637f0-dec3-4bd1-9648-a823c140669b%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/rubyonrails-talk/511637f0-dec3-4bd1-9648-a823c140669b%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/rubyonrails-talk/39ae14f7-72e1-48c3-9d44-371a4e9a799f%40googlegroups.com?utm_medium=email&amp;utm_source=footer" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/rubyonrails-talk/39ae14f7-72e1-48c3-9d44-371a4e9a799f%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/rubyonrails-talk/39ae14f7-72e1-48c3-9d44-371a4e9a799f%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/rubyonrails-talk/39ae14f7-72e1-48c3-9d44-371a4e9a799f%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="CufZlxhjBQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">rubyonra...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/rubyonrails-talk/9021a944-10e2-4320-9c2f-b5b68743fb8e%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/rubyonrails-talk/9021a944-10e2-4320-9c2f-b5b68743fb8e%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/rubyonrails-talk/9021a944-10e2-4320-9c2f-b5b68743fb8e%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/rubyonrails-talk/9021a944-10e2-4320-9c2f-b5b68743fb8e%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/e8b46fc5-8dea-4185-a282-3f61d80f5cbe%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Why do basic forms not work in Rails 6 without binding events to each form?

Jason Fleetwood-Boldt
In reply to this post by San Ji

I'm not suggesting any breaking changes at all. 

I've been using Rails since Rails version 2 so I don't know what you mean "like that from the beginning"

In the beginning, DHH said things would "just work" and, as a community we would value convention over configuration. 


As far as using ActiveModel with the form_with, I don't think that's relevant, it wouldn't make any difference as to behavior. 

All I'm suggesting is that Turbolinks is too complicated and should be OFF by default, like a lot of other things, so that it could be opted-into by the dev instead of forced upon us by the framework.





On Tuesday, February 18, 2020 at 1:41:03 PM UTC-5, San Ji wrote:
I don't think you can blame Rails 6 for that. It is a weird default, but it is like that from the very beginning.
I never use the method, so, I guess, it can be considered as somewhat obscure. It seems to appear in Rails version 5.1 and no change since.
Normally, I would use ActiveModel for a local form. Just in case you don't know, ActiveModel can also be used independently from ActiveRecord.

This is the earliest docs I found.
<a href="https://api.rubyonrails.org/v5.1/classes/ActionView/Helpers/FormHelper.html#method-i-form_with" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fapi.rubyonrails.org%2Fv5.1%2Fclasses%2FActionView%2FHelpers%2FFormHelper.html%23method-i-form_with\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGrhPjr8VrIs2YiMriXZCbNQI56Hw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fapi.rubyonrails.org%2Fv5.1%2Fclasses%2FActionView%2FHelpers%2FFormHelper.html%23method-i-form_with\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGrhPjr8VrIs2YiMriXZCbNQI56Hw&#39;;return true;">https://api.rubyonrails.org/v5.1/classes/ActionView/Helpers/FormHelper.html#method-i-form_with

Guess someone already complained, but it is too late; there is no good reason to introduces breaking changes for a better default.
Also, in a sense, this can be the better default, since ActiveModel is there for you to build a form for the same app.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/24f5f9ba-0d91-4279-bf10-841c06a2463a%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Why do basic forms not work in Rails 6 without binding events to each form?

San Ji
For your information, the context of my previous post is focused on form_with, the method in the discussion.

But, for broader sense, Basecamp and DHH are great and generous companion to be in the same community. You can't find community like this somewhere else.

However, we all eventually grow up from the Rails way.
You are frustrating with Turbolinks, et al, these are normal.
Me too, have the same experience, my project don't even use Active Record, for me it is a pain, and every design based on ER diagram is usually subpar IMO.

However, I won't give up on Rails, it is so far beyond other community from my point of view. After all Rails is just a bunch of libraries, if you don't like some, just ignore it, the benefit from the community is far exceeding it down side.

And you too, should see it already, or you won't stick to it this long.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/1292fc26-7877-49e3-b006-63162a5490cc%40googlegroups.com.