views:

45

answers:

2

Hi,

I got the problem similar to this post here: https://rails.lighthouseapp.com/projects/8994/tickets/106-authenticity_token-appears-in-urls-after-ajax-get-request

routes.rb

  map.namespace(:admin,  :active_scaffold => true) do |admin|
    admin.resources :regions, :shallow => true do |region| 
      region.resources :birds, :collection => {:search => :get}
    end 
  end

view

  <%= javascript_tag %Q(
    #{remote_function(:update => 'bird_search', :url => search_admin_region_birds_path(@region.id), :method => :get)}
  ) %>

It displays url like: http://localhost:3000/admin/regions/7/birds/search?authenticity_token=F43BcQUM4z3bl7s21kLZQrqwGkuErF7C9jiNMKFTZTo%3D

which should be: http://localhost:3000/admin/regions/7/birds/search

Without this working my Ajax pagination won't work... help!

A: 

what version of rails are you using? that ticket says it was closed out, maybe you are on earlier version

http://api.rubyonrails.org/classes/ActionView/Helpers/PrototypeHelper.html#M001653 the example output does not have the auth token

house9
I am using the newest, version 2.3.5Wondering if it is a rails bug?
jaycode
A: 

Fixed this by using Javascript instead of using RJS.

Many times RJS methods aren't very dependable when your apps get more complicated, so take care there.

Anyway for this problem I changed the code to:

  <%= javascript_tag %Q(
    new Ajax.Updater('region_birds', '#{of_region_admin_region_birds_path(@region.id)}', {asynchronous:true, evalScripts:true, method:'get'});
  ) %>
jaycode