Rails 2.0.2で、auto_completeを使うと、
ActionController::InvalidAuthenticityToken (ActionController::InvalidAuthenticityToken):
というエラーが出る。これは、Rails 2.xの新機能のCSRF (Cross-Site Request Forgery)プロテクションにauto_completeプラグインが対応してないから。Rubyonrails-talk MLに、お答えがあったので、参考にさせてもらう。
prototype_helperが、authenticity tokenをセットしてる辺りのコードを、auto_complete pluginのauto_complete_macros_helperにコピーしたら、うまく動いた。
こんな感じです:
js_options[:method] = "'#{options[:method].to_s}'" if options[:method] ## protect_against_forgery patch begin ## Updated to render forgery_protection_token if protect_against_forgery? if js_options['parameters'] js_options['parameters'] << " + '&" else js_options['parameters'] = "'" end js_options['parameters'] << "#{request_forgery_protection_token}=' + encodeURIComponent('#{escape_javascript form_authenticity_token}')" end ## protect_against_forgery patch end { :after_update_element => :afterUpdateElement,