2010-04-16 48 views
1

我有类似这样的帖子在这里的问题:https://rails.lighthouseapp.com/projects/8994/tickets/106-authenticity_token-appears-in-urls-after-ajax-get-requestremote_function不断增加对GET真实性令牌请求

的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 

视图

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

它显示的网址,如: http://localhost:3000/admin/regions/7/birds/search?authenticity_token=F43BcQUM4z3bl7s21kLZQrqwGkuErF7C9jiNMKFTZTo%3D

这应该是: http://localhost:3000/admin/regions/7/birds/search

没有这个工作,我的Ajax分页将无法工作......帮助!

回答

0

通过使用Javascript,而不是使用RJS修正这一点。

当你的应用程序变得更加复杂时,很多时候RJS方法都不是很可靠,所以要小心。

反正对于这个问题,我改变了代码:

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