初学flex3和rails2的问题
第一次写东西,请大家多多指教。
如题:总是提示如下错误:
发生ActionScript错误
[RPC Fault FaultString="HTTP request error" faultCode="Server.Error.Request" faultDetail="Error:.URL: http://localhost:3000/bugs/update"]
at mx.rpc::AbstractInvoker/http://www.adobe:com/2006/flex/mx/internal::faultHandler()
at mx.rpc::Responder/fault()
at mx.rpc::AsyncRequest/fault()
at flash.events::EventDispatcherdispatchEventFunction()
at.flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/redirectEvent()
查看了一下,rails development/log,找到 /usr/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/request_forgery_protection.rb这个文件,把其中的以下部分: def verified_request? !protect_against_forgery? || request.method == :get || !verifiable_request_format? || form_authenticity_token == params end 改写为: def verified_request? !protect_against_forgery? || request.method == :post || request.method == :get || !verifiable_request_format? || form_authenticity_token == params end
程序可正常运转。
我最近也在研究flex3与rails2
有可能的话,大家多多交流
这样子的话你就可以方便的XML数据与RAILS进行通信(采用REST接口)
同时也可以在使用HTML与AJAX的同时防止XRSS攻击
估计是request_forgery_protection的原因
但一般你不用去改的
一般RequestForgeryProtection只会对html及js类型的申请进行token检查
如果你使用的是flex端,你可以使用xml的形式发起请求:
比如: <mx:HTTPService id="svcBugUpdate" result="handleBugsUpdateResult(event)" method="POST" resultFormat="e4x"/>
public function updateBug(bug:XML):void{ var params:Object = new Object(); params"] = "bugname"; params"] = "bug body"; params = "PUT"; svcBugUpdate.url = "/bugs/" + bug.id + ".xml"; svcTaskUpdate.send(params); }
学习中..............