0
發送消息
我application_controller.rb
:王菲+導軌+在控制器
class ApplicationController < ActionController::Base
def broadcast(channel, &block)
message = {:channel => channel, :data => capture(&block)}
uri = URI.parse("http://localhost:9292/faye")
Net::HTTP.post_form(uri, :message => message.to_json)
end
end
在posts_controller.rb
,我想這樣做:
def create
broadcast("/posts/new") do
$('.user-win .posts').prepend('j(render('/posts/broadcast'))'));"
end
end
但很明顯,它給出了一個錯誤:
ArgumentError (wrong number of arguments (0 for 1))
app/controllers/application_controller.rb:21:in `broadcast'
有什麼建議嗎?