2014-07-23 9 views
22

जब इस तरह विरासत नियंत्रक परीक्षण चलाने:ActionController :: नियंत्रक टेस्ट में InvalidCrossOriginRequest

ActionController::InvalidCrossOriginRequest: Security warning: an embedded <script> tag on another site requested protected JavaScript. If you know what you're doing, go ahead and disable forgery protection on this action to permit cross-origin JavaScript embedding. 

उत्तर

17

रेल के लिए 5+

get :edit, params: { id: object.id }, xhr: true 
35

पुराने रेल के संस्करण स्वीकृत:

get :edit, id: object.id, format: :js 

मेरे परीक्षण निम्न त्रुटि के साथ रेल 4.1 में नाकाम रहने के लिए शुरू किया यह, लेकिन समाधान xhr विधि का उपयोग निम्न प्रकार से किया गया था:

xhr :get, :edit, id: object.id 
+3

यह सिंटैक्स रेल 5 में संपादित_url (ऑब्जेक्ट), xhr: true' में बदल गया है। –

संबंधित मुद्दे