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" %>

with

    <%= 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
code:

<%= 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: *
"/home/carlton/memory/app/views"

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

text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8

(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.

Thanks,
David Carlton
carl...@bactrian.org

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to