Ruby on Rails Thursday, June 25, 2015

Railscasts does a lot of configuration before having it working. Why is there not a functioning default?

Responder will answer 204, but why is this not default in either `form_for` or UJS?

What is the expected use case and can it be documented? I suspect it's the latter, but I expected there to be good defaults in place.
 

On Thursday, June 18, 2015 at 8:29:57 AM UTC-4, Elizabeth McGurty wrote:
Check out RailsCasts:

Ruby on Rails - Railscasts PRO #136 jQuery & Ajax (revised)

https://www.youtube.com/watch?v=FBxVN7U1Qsk



On Thursday, June 18, 2015 at 2:41:53 AM UTC-4, Jonathan Allard wrote:
With Convention over configuration, you can usually trust the defaults to get you there. In this case, not so much. I've been banging my head on the wall for a few hours now, in between trying things and researching.

For the usual cases, how do I set up an AJAX form. Is it using JS or JSON format?

**Case 1: `form_for remote: true` default, `format.js`**

UJS sends a request as JS. 
Exception: Missing template for update.js.

`form_for remote: true, format: :json`

No difference in HTML output, though `form_for` doc examples says you can do that.

**Case 2: `form_for remote: true, html: {"data-type" => :json}` not the default**

Responder will answer 204, but why is this not default in either `form_for` or UJS?

What is the expected use case and can it be documented? I suspect it's the latter, but I expected there to be good defaults in place.

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/3b41f0d3-d71d-462b-b33d-c009962374ea%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment