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

2020-02-18 Thread 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 ()
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:
>
>
> 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 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 ()
>> 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 (<
>>> arie...@gmail.com>) 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 (<
 te...@datatravels.com>) 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 (<
>> te...@datatravels.com>) 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.
>>>
>>>
>>> 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 ,
>>> 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

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

2020-02-18 Thread San Ji
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 rubyonrails-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/3e340425-4707-456e-9f3c-4a1a6fa09bc8%40googlegroups.com.


[Rails] Delayed job :: URGENT

2020-02-18 Thread Shubham Thakur
Hi, 

I am bit confused in rails delayed job

1) what is workers
2) what is process?
3) both workers and processes are same ???

-- 
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 rubyonrails-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/34a0c565-175e-4fa9-bc61-f2f8523c20a4%40googlegroups.com.


[Rails] Delayed job::WORKERS

2020-02-18 Thread Shubham Thakur
Hi,

I have around 25000, records and I want to save it into database using 
rails delayed job.

but its taking around 45-50 min, can anyone suggest me how can I do it 
faster.

Thanks.

-- 
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 rubyonrails-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/314e9e42-4a64-42d1-bb34-5658ac24bfcd%40googlegroups.com.


Re: [Rails] Delayed job::WORKERS

2020-02-18 Thread Hasan Diwan
https://github.com/zdennis/activerecord-import may be helpful to you,
Shubham.

On Tue, 18 Feb 2020 at 22:21, Shubham Thakur 
wrote:

> Hi,
>
> I have around 25000, records and I want to save it into database using
> rails delayed job.
>
> but its taking around 45-50 min, can anyone suggest me how can I do it
> faster.
>
> Thanks.
>
> --
> 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 rubyonrails-talk+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/rubyonrails-talk/314e9e42-4a64-42d1-bb34-5658ac24bfcd%40googlegroups.com
> 
> .
>


-- 
OpenPGP:
https://sks-keyservers.net/pks/lookup?op=get=0xFEBAD7FFD041BBA1
If you wish to request my time, please do so using
*bit.ly/hd1AppointmentRequest
*.
Si vous voudrais faire connnaisance, allez a *bit.ly/hd1AppointmentRequest
*.

Sent
from my mobile device
Envoye de mon portable

-- 
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 rubyonrails-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/CAP%2BbYWCxdvOVDLTrnSA1kKj_Ucx9NswS178-f4uJ6tC1oJAPkQ%40mail.gmail.com.


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

2020-02-18 Thread 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 ()
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 (<
> t...@datatravels.com>) 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 (<
>>> te...@datatravels.com>) 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.


 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 ,
 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 "ERROR"


 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 rubyonra...@googlegroups.com.
 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 rubyonrails-talk+unsubscr...@googlegroups.com.
>> 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 

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

2020-02-18 Thread 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 ()
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 (<
> arielj...@gmail.com>) 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 (<
>> t...@datatravels.com>) 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 (<
 te...@datatravels.com>) 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.
>
>
> 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 ,
> 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 "ERROR"
>
>
> 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 rubyonra...@googlegroups.com.
> 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 rubyonrails-talk+unsubscr...@googlegroups.com.
>>> To view this discussion on the web visit
>>> 

Re: [Rails] redirect shown in log, but browser not redirecting

2020-02-18 Thread Momeas Interactive
Nicholas,

With all due respect, if you "wrote the docs on form_with," I would refer 
you to my previous thread in which I am complaining about Turbolinks being 
default (I think it shouldn't be).

You will also note that the only place local: true appears on the form_with 
documentation is in a "red alert" box, as if it is a side-note or "extra 
information," and you have to read through almost half of the entire 
document to find this obscure yet vital piece of information.

For something that makes Rails basically non-usable as a modern web 
framework out-of-the-box, I seriously think you should consider that the 
'local: true' information and all this easy casual encouragement for 
newbies to "just skip turbolinks this way"  (which is a fine choice if you 
know what you're doing) is somewhat careless. 

Either of 3 things should happen here:
1) If this is so non-intuitive it should be much more prominent in the docs 
than it is. Like, top -of-page prominent. Why are there separate settings 
for 'local: true' and 'remote: true' anyway? Doesn't that confuse anybody 
else. Why wouldn't you simply pass 'remote: false' (which doesn't currently 
work) and do-away with  another setting to remember?

2) *Turbolinks should be removed as the default for rails and should be an 
opt-in technology like many other things which once were in Rails core and 
now aren't. There's just too many devs turning it off left & right and too 
many people getting stuck and slowed down by it to justify it staying as 
the default.*

3) If new entrants are coming to the Rails framework, it needs to be 
explained to them this is an advanced complicated framework and in order to 
get basics to work you need to understand how to bind Ajax events. It is no 
longer a 'minutes to learn' framework as it was when it was invented and 
this is a *perfect example* of the barriers to entry that we are putting up 
for new entrants. 


(you'll note my preference because it is in boldface above)


Jason




On Saturday, February 15, 2020 at 1:30:06 AM UTC-5, Nicholas Schwaderer 
wrote:
>
> Fugee,
>
> Replace:
>
> “remote: false” with “local: true” and tell me if that works for you.
>
> Source: I wrote the docs on form_with.
>
> -Schwad
>
> Sent from my iPhone
>
> On 14 Feb 2020, at 10:52 pm, fugee ohu > 
> wrote:
>
>
>
> On Friday, February 14, 2020 at 12:04:55 PM UTC-5, Walter Lee Davis wrote:
>>
>> Is your form set to the default of an Ajax submission, or did you add the 
>> configuration flag to the form_with method call that makes it actually 
>> redirect? If this was a redirect, the header would be 301, not 200. 
>>
>> Walter
>>
>> On Feb 14, 2020, at 9:59 AM, fugee ohu  wrote:
>>
>> 
>> This is a redirect from my log, but page doesn't change I'm still on the 
>> same page containing the form I submitted
>>
>> 127.0.0.1 - - [14/Feb/2020:11:55:46 EST] "GET /artists/72/press_releases 
>> HTTP/1.1" 200 2542
>> http://localhost:3000/artists/72/tours/1 -> /artists/72/press_releases
>>
>> -- 
>> 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 rubyonra...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/rubyonrails-talk/be527a35-e686-4968-8849-ca05ecfc2491%40googlegroups.com
>>  
>> 
>> .
>>
>>
> Well I hope you're still with me on this cause I solved it and I don't 
> have anyone else to tell For some reason I had commented out `gem 
> turbolinks`  in my Gemfile I'm upgrading all my apps to rails 6 and really 
> to webpacker I remember reading somewhere the new way of doing things is to 
> not use turbolinks I don't remember where 
>
> -- 
> 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 rubyonra...@googlegroups.com .
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/2aab187e-810f-4122-8318-fd6ced48d405%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 rubyonrails-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/816c3295-c5fd-40c0-bdce-53a039dce323%40googlegroups.com.


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

2020-02-18 Thread Momeas Interactive
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 (<
> te...@datatravels.com >) 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. 
>>
>>
>> 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 , 
>> 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 "ERROR"
>>
>>
>> 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 rubyonra...@googlegroups.com .
>> 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 rubyonrails-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/39ae14f7-72e1-48c3-9d44-371a4e9a799f%40googlegroups.com.


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

2020-02-18 Thread 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 ()
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 (<
>> te...@datatravels.com>) 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.
>>>
>>>
>>> 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 ,
>>> 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 "ERROR"
>>>
>>>
>>> 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 rubyonra...@googlegroups.com.
>>> 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 rubyonrails-talk+unsubscr...@googlegroups.com.
> 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 rubyonrails-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/CAPS3bcD3pz32uZN%3DPMOBRkM%3DdRr%2BGqCxS5o5zV9ChUQLdzpDyA%40mail.gmail.com.


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

2020-02-18 Thread Momeas Interactive

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:

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 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 ( >) 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 (> >) 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 (<
>>> te...@datatravels.com >) 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 (<
> te...@datatravels.com>) 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. 
>>
>>
>> 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 , 
>> 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 "ERROR"
>>
>>
>> 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 

Re: [Rails] //= require stylesheet with webpacker

2020-02-18 Thread Momeas Interactive
Fugee-


when you switch from css to scss, you need to rename application.css to 
application.scss and do the following:

*stop using //= require*

instead use @import always and from now on when using scss. Do not use *//= 
require *syntax anymore

this is explained in the "IMPORTANT NOTE" at the top of the sass-rails docs:

https://github.com/rails/sass-rails#important-note


if you are trying to install Bootstrap, there are some bad tutorials on the 
internet. I think one of them tells you to put the bootstrap.scss into your 
application.js file. Don't do that.

instead backtrack on what you did and use webpack to install Bootstrap 
(this is NOT the same as the 'old way' which you could still do on a Rails 
6 app), simple instructions here : 
https://gorails.com/forum/install-bootstrap-with-webpack-with-rails-6-beta

-jason








On Saturday, January 18, 2020 at 10:23:56 PM UTC-5, fugee ohu wrote:
>
>
>
> On Saturday, January 18, 2020 at 11:11:11 AM UTC-5, Ariel Juodziukynas 
> wrote:
>>
>> "//= require ..." is Sprocket's syntax (most known as rails' assets 
>> pipeline), not webpacker's. If you really want to handle CSS assets with 
>> webpacker you should start by reading this 
>> https://github.com/rails/webpacker/blob/master/docs/css.md
>>
>> El sáb., 18 ene. 2020 a las 4:00, fugee ohu () 
>> escribió:
>>
>>> I have my stylesheet in app/javascript/stylesheets and need to include 
>>> actiontext.scss in application.scss where both files are located in 
>>> app/javascript/stylesheets but using 
>>> //= require actiontext has no effect, styling is still not being applied
>>>
>>> -- 
>>> 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 rubyonra...@googlegroups.com.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/rubyonrails-talk/58c1a214-6a7c-4b16-8e02-60a17cbb15d9%40googlegroups.com
>>>  
>>> 
>>> .
>>>
>>
> Nothing in there about loaders I'm trying to get actiontext.scss to load I 
> have listed in app/javascripts/packs/application.js
> import "../stylesheets/actiontext.scss"
> but the styling's  not being applied
>

-- 
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 rubyonrails-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/67ee24bd-88bd-4289-b865-bb0c77eea749%40googlegroups.com.


[Rails] Re: Setting model association `source_type` to polymorphic object

2020-02-18 Thread Momeas Interactive
I don't think polymorphism in Rails can work that way 

did you try


`has_many :users_following, through: :active_relationships, source: 
:followable, source_type: "FollowableUser"`

`has_many :projects_following, through: :active_relationships, source: 
:followable, source_type: "FollowableProject"`




On Monday, February 10, 2020 at 5:45:41 AM UTC-5, UG wrote:
>
> I am trying to setup a way for my `User` and `Project` model to both be 
> followed through the same `Relationship` model.
>
> I also want to be able to get all items the user has followed with this 
> association:
> `has_many :following, through: :active_relationships, source: :followable, 
> source_type: "Followable"`
>
>
> This way, the projects and users any user has followed can be called with 
> `user.following`. In this case, `Followable` is the polymorphic object that 
> is attributed to both users and projects. Unfortunately, it seems that I 
> cannot set my source_type to a polymorphic object. Is there a way I can 
> bypass this?
>
> Many thanks
>
>
>

-- 
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 rubyonrails-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/0facc107-25e3-4eea-9bae-753e5488ed7e%40googlegroups.com.


[Rails] Re: Setting model association `source_type` to polymorphic object

2020-02-18 Thread UG


On Tuesday, February 18, 2020 at 6:59:15 PM UTC+1, Momeas Interactive wrote:
>
> I don't think polymorphism in Rails can work that way 
>
> did you try
>
>
> `has_many :users_following, through: :active_relationships, source: 
> :followable, source_type: "FollowableUser"`
>
> `has_many :projects_following, through: :active_relationships, source: 
> :followable, source_type: "FollowableProject"`
>
>
>
Yeah I guess that would work. I would need to change a lot in my code but 
yeah I could do that. It's too bad if you can't do it in Rails 

-- 
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 rubyonrails-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/b3df4b44-223e-42aa-a2d2-737a86cc09a9%40googlegroups.com.