Rails 3 和 AMF 、rails3-amf、RocketAMF 的问题
我正在尝试让 AMF 与 Rails3 一起使用。 我已经成功安装了rails3-amf-0.1.0 gem 和RocketAMF-0.2.1 gem。
在我的应用程序中,有一个具有以下代码的控制器:
def getRandomCards
@incoming = params[0]
@cards = Cardvo.first
respond_with(@cards) do |format|
format.amf { render :amf => @cards.to_amf}
end
end
通过 Actionscript 的调用,我想返回一些 amf 格式的数据。
此外,正如 Rails3-amf 的说明中提到的,我执行了以下操作。 在我的 config/environment 下的 production.rb 中,我添加了
config.rails3amf.map_params :controller => 'CardvosController', :action => 'getRandomCards'
我的 amf 网关的
config.rails3amf.gateway_path = "/gateway"
行问题是:
来自 Actionscript / Flash 的任何调用都会引发以下问题 (摘自日志)
Started POST "/gateway" for 192.178.168.1 at Fri Nov 19 15:13:28 +0100 2010
Processing by CardvosController#getRandomCards as AMF
Parameters: {0=>100.0}
[1m[36mSQL (0.4ms)[0m [1mSHOW TABLES[0m
[1m[35mCardvo Load (0.2ms)[0m SELECT `cardvos`.* FROM `cardvos` LIMIT 1
Completed 200 OK in 13ms (Views: 0.9ms | ActiveRecord: 0.5ms)
NoMethodError (undefined method `constructed?' for #<RocketAMF::Envelope:0x39ba868>):
Amf 文件已创建,但无法找到 RocketAMF 的 remoting.rb 中的方法。 我认为错误是在 Rails3AMF 的 request_parser.rb 处引发的,要求构造?
# Wrap request and response
env['rack.input'].rewind
env['rails3amf.request'] = RocketAMF::Envelope.new.populate_from_stream(env['rack.input'].read)
env['rails3amf.response'] = RocketAMF::Envelope.new
# Pass up the chain to the request processor, or whatever is layered in between
result = @app.call(env)
# Calculate length and return response
if env['rails3amf.response'].constructed?
对我来说,它似乎正在寻找错误的方法类。 在哪里 NoMethodError(#RocketAMF::Envelope:0x39ba868 的未定义方法“构造?”):
基本部分是 RocketAMF::信封:0x39ba868 应该是 RocketAMF:ANOTHER_CLASS:Envelope:0x39ba868
我说得对吗?错误到底在哪里? 任何帮助将不胜感激!
克里斯
im trying to get AMF to work with Rails3.
I have succesfully installed rails3-amf-0.1.0 gem and the RocketAMF-0.2.1 gem.
In my app there is a controller with the following code:
def getRandomCards
@incoming = params[0]
@cards = Cardvo.first
respond_with(@cards) do |format|
format.amf { render :amf => @cards.to_amf}
end
end
through a call from Actionscript i would like to return some data in amf format.
further more, as mentioned in the instructions for rails3-amf i did the following.
in my production.rb under config/environment i added the line
config.rails3amf.map_params :controller => 'CardvosController', :action => 'getRandomCards'
an my amf gateway got
config.rails3amf.gateway_path = "/gateway"
The problem is:
Any call from Actionscript / Flash raises the following
(taken from the log )
Started POST "/gateway" for 192.178.168.1 at Fri Nov 19 15:13:28 +0100 2010
Processing by CardvosController#getRandomCards as AMF
Parameters: {0=>100.0}
[1m[36mSQL (0.4ms)[0m [1mSHOW TABLES[0m
[1m[35mCardvo Load (0.2ms)[0m SELECT `cardvos`.* FROM `cardvos` LIMIT 1
Completed 200 OK in 13ms (Views: 0.9ms | ActiveRecord: 0.5ms)
NoMethodError (undefined method `constructed?' for #<RocketAMF::Envelope:0x39ba868>):
The Amf file is created but the method, which is in remoting.rb from RocketAMF could not be found.
I think the error is thrown at request_parser.rb from Rails3AMF asking for constructed?
# Wrap request and response
env['rack.input'].rewind
env['rails3amf.request'] = RocketAMF::Envelope.new.populate_from_stream(env['rack.input'].read)
env['rails3amf.response'] = RocketAMF::Envelope.new
# Pass up the chain to the request processor, or whatever is layered in between
result = @app.call(env)
# Calculate length and return response
if env['rails3amf.response'].constructed?
For me it seems it is looking at the wron class for the method.
Where
NoMethodError (undefined method `constructed?' for #RocketAMF::Envelope:0x39ba868):
the essential part is
RocketAMF::Envelope:0x39ba868
which should be
RocketAMF:ANOTHER_CLASS:Envelope:0x39ba868
Am i right and where the heck is the error ?
Any help would be appreciated!
chris
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论