Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #11591: support_forgery_patch.diff

File support_forgery_patch.diff, 1.1 kB (added by CreatixEA, 6 months ago)

Path to applied to the plug-in to get it working with forgery

  • lib/auto_complete_macros_helper.rb

    old new  
    6969    js_options[:paramName]  = "'#{options[:param_name]}'" if options[:param_name] 
    7070    js_options[:frequency]  = "#{options[:frequency]}" if options[:frequency] 
    7171    js_options[:method]     = "'#{options[:method].to_s}'" if options[:method] 
     72         
     73        # Emilien ARNAUD changes - add the authenticity token with exactly the same code 
     74    # from the prototype_helper: 
     75    if protect_against_forgery? 
     76      if js_options[:parameters] 
     77        js_options[:parameters] << " + '&" 
     78      else 
     79        js_options[:parameters] = "'" 
     80      end 
     81      js_options[:parameters] << "#{request_forgery_protection_token}=' +  encodeURIComponent('#{escape_javascript form_authenticity_token}')" 
     82    end 
     83    # End of Emilien ARNAUD changes 
    7284 
    7385    { :after_update_element => :afterUpdateElement,  
    7486      :on_show => :onShow, :on_hide => :onHide, :min_chars => :minChars }.each do |k,v|