I found a solution here:

https://github.com/rails/jquery-ujs/issues/issue/52

On Jan 18, 12:07 pm, Mike C <snib...@gmail.com> wrote:
> I forgot to mention that I'm using jQuery. I tried ajax using
> prototype in a test app and it worked, but when I use jQuery it
> doesn't work. However, when using jQuery it will work if I use rjs but
> I really don't want to do that. It seems to me that when I'm using
> jQuery, it doesn't recognize the .js.erb files. As far as I know, I'm
> using the most recent version of jQuery and the most recent version of
> the rails driver for it.
>
> On Jan 14, 8:47 pm, Mike C <snib...@gmail.com> wrote:
>
>
>
> > My ajax stopped working when I switched to using respond_with. For my
> > Votes, I have the create action and the corresponding create.js.erb,
> > and respond_to :html, :js, :xml in the controller. Heres the log when
> > I try and create a vote:
>
> > Started POST "/stories/3-asdfasdf1111/votes" for 127.0.0.1 at Fri Jan
> > 14 20:46:36 -0800 2011
> >   Processing by VotesController#create as */*
> >   Parameters: {"story_id"=>"3-asdfasdf1111"}
> >   SQL (1.9ms)  SHOW TABLES
> >   SQL (2.0ms)  SHOW TABLES
> >   SQL (2.5ms)  SHOW TABLES
> >   User Load (2.4ms)  SELECT `users`.* FROM `users` WHERE (`users`.`id`
> > = 3) LIMIT 1
> >   CACHE (0.0ms)  SELECT `users`.* FROM `users` WHERE (`users`.`id` =
> > 3) LIMIT 1
> >   Story Load (2.4ms)  SELECT `stories`.* FROM `stories` WHERE
> > (`stories`.`id` = 3) LIMIT 1
> >   SQL (0.4ms)  BEGIN
> >   Vote Load (0.7ms)  SELECT `votes`.`id` FROM `votes` WHERE
> > (`votes`.`user_id` = 3) AND (`votes`.`story_id` = 3) LIMIT 1
> >   SQL (1.4ms)  ROLLBACK
> > Completed   in 1466ms
>
> > ActionView::MissingTemplate (Missing template votes/new with
> > {:locale=>[:en, :en], :handlers=>[:builder, :rjs, :rhtml, :erb, :rxml, 
> > :haml], :formats=>[:html]}
> > in view paths "/Users/snibble/Projects/Ruby/storychan/app/views", "/
> > Users/snibble/Projects/Ruby/storychan/vendor/plugins/white_list/app/
> > views"):
> >   app/controllers/votes_controller.rb:16:in `create'
>
> > Rendered /opt/local/lib/ruby/gems/1.8/gems/actionpack-3.0.3/lib/
> > action_dispatch/middleware/templates/rescues/missing_template.erb
> > within rescues/layout (1.0ms)
>
> > The votes controller only has the create option:
>
> >   def create
> >     @story = Story.find(params[:story_id])
> >     @vote = @story.votes.create(:user => current_user)
>
> >     if @vote.errors.empty? && @vote.valid?
> >       flash[:notice] = 'Successfully voted!'
> >     else
> >       flash[:error] = 'You already voted for that story!'
> >     end
>
> >     respond_with @vote
> >   end

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