James Lavin
2011-May-13 16:30 UTC
Form submission should return javascript but returns "406 Not Acceptable"
I have a form that submits fine and is processed by the controller but
began failing to return Javascript (around the time I upgraded to 3.0.7)
and instead generates a "406 Not Acceptable."
I''ve tried everything I can think of to get this working again, and
I''m
completely baffled.
I''ve stripped the problem down to the following:
config/routes:
match ''my_words/test_create(.:format)'' =>
''my_words#test_create''
whatever.html.erb:
<%= form_tag(url_for("/my_words/test_create.js"), :format =>
:js,
"data-type" => "script", :remote => true) do %>
<%= submit_tag "Test JS" %>
<% end %>
app/controllers/my_words_controller.rb:
# I don''t think this is necessary, but I''m trying to isolate
the
problem
authenticate_user! :except => [:test_create]
...
def test_create
respond_to do |format|
format.js { render :js => "alert(''This much
works'');" }
end
end
From development.log:
Started POST "/my_words/test_create.js" for 127.0.0.1 at Fri May 13
12:13:01 -0400 2011
Processing by MyWordsController#test_create as JS
Parameters: {"utf8"=>"✓",
"authenticity_token"=>"xxxxxxx"}
Completed 406 Not Acceptable in 2ms
From Firebug:
Response Headers
Cache-Control no-cache
x-ua-compatible IE=Edge,chrome=1
Set-Cookie _xxxxxx_session=xxxxxx; path=/; HttpOnly
X-Runtime 0.095000
Content-Type text/html;charset=utf-8
Content-Length 1
Date Fri, 13 May 2011 16:13:01 GMT
Request Headers
Host localhost:3005
User-Agent Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.17)
Gecko/20110422 Ubuntu/10.10 (maverick) Firefox/3.6.17
Accept text/javascript, application/javascript, */*; q=0.01
Accept-Language en-us,en;q=0.5
Accept-Encoding gzip,deflate
Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive 115
Connection keep-alive
Content-Type application/x-www-form-urlencoded; charset=UTF-8
X-Requested-With XMLHttpRequest
X-CSRF-Token xxxxxxxx
Referer http://localhost:3005/home/article/10671
Content-Length 82
Cookie socketio=xhr-multipart; xxxxxxx
Any ideas?
Thanks so much!
James
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
James Lavin
2011-May-13 16:34 UTC
Re: Form submission should return javascript but returns "406 Not Acceptable"
The first line in app/controllers/my_words_controller.rb is actually: before_filter :authenticate_user!, :except => [:test_create] (I should have copied-and-pasted.) -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
James Lavin
2011-May-13 18:47 UTC
Re: Form submission should return javascript but returns "406 Not Acceptable"
I used my Git time machine to revert to my last known good state. I updated to the latest rails.js and everything still worked. I then updated to JQuery 1.6.1 and everything broke. I backed up to JQuery 1.5.2 and some (but not all) things were broken. I backed up to JQuery 1.4.4 and things worked again. I updated from Rails 3.0.5 to 3.0.7 and things still apparently work. So it''s looking like a JQuery problem. Anyone else hit this problem? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
In case anyone else experiences my problem... My "JQuery 1.5.2" problem was actually caused by the latest versions of HAML and Kaminari not playing well together. So my Ajax form submission troubles may all be caused by JQuery 1.6.1. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.