我在这里订阅了PubSub
ul.questions_list
-if(@questions.empty?)
|no questions available
-else
-@questions.each do|question|
li
=link_to"#{ question.title } ", question_path(question)
p= link_to 'Ask question', new_question_path
= subscribe_to '/questions'
然后去咖啡(在这种情况下,console.log提供正确的数据)
$ ->
PrivatePub.subscribe '/questions', (data, channel) ->
question = $.parseJSON(data['question'])
console.log(question.title)
$('.questions_list').append("<li><a href='/questions/#{question.id}'>#{question.title}</a></li>");
和控制器
def create
@question = Question.new(question_params)
@question.user = current_user
if @question.save
PrivatePub.publish_to '/questions', question: @question.to_json
redirect_to @question, notice: 'Your question successfully created.'
else
render :new
end
end
我收到了这样的错误
The connection to ws://localhost:9292/faye was interruped while the page was loading.
...et;t.exports={create:function(t){return **new** n(t)}}}).call(e.function(){return th...)
我不明白我做错了。非常感谢任何帮助
答案 0 :(得分:0)
我删除了数据库,现在一切正常。谁能解释发生了什么?