I have an old Rails application that I'd previously upgraded to Rails 3.1
with a lot of legacy features left on; now I want to switch to using jQuery
instead of Prototype, and switch to using the asset pipeline.

I'm trying to tackle the first of those; no idea if that's wise, maybe I
should start with the asset pipeline instead? To switch to jQuery, I added

gem 'jquery-rails'

to my Gemfile and replaced

<%= javascript_include_tag "prototype", "rails" %>


<%= javascript_include_tag "
http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js" %>
<%= javascript_include_tag "rails" %>

(I suspect that I'm doing something pretty wrong there, but I don't know
what.) And I removed all the prototype-specific JavaScript from my files.

The problem that I'm running into is this: I have a form with the following

<%= form_tag url_for(:action => :answer, :item => ask), :remote => true, :id
=> "show-answer" do %>
<%= submit_tag "Answer" %>
<% end %>

It's supposed to return the response from answer.js.erb. Unfortunately, when
I do that, I get the following complaint:

template quiz/answer, application/answer with {:handlers=>[:builder, :erb],
:formats=>[:html], :locale=>[:en, :en]}. Searched in: *

So it's looking for HTML instead of JavaScript; and, indeed, the Accept:
header says:


(I guess that */* at the end is too low priority for it to have an effect.)
I tried explicitly responding only to format.js in my controller action, but
then I got a 406 Not Acceptable response.

Any suggestions as to how I'm wiring this wrong? (I have no idea where that
Accept: header is coming from, I'm certainly not setting it.) I guess the
next thing I'll try is switching over to the asset pipeline; it's not clear
to me why that would make a difference, but I don't really understand how
the jquery-rails gem takes effect, so it's entirely possible that I'm
inadvertently completely bypassing it somehow.

David Carlton

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@googlegroups.com.
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.

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
postedSep 25, '11 at 5:55p
activeSep 25, '11 at 5:55p

1 user in discussion

David Carlton: 1 post



site design / logo © 2021 Grokbase