首页 \ 问答 \ 与Faye的消息:ReferenceError:未定义Faye(Messaging with Faye : ReferenceError: Faye is not defined)

与Faye的消息:ReferenceError:未定义Faye(Messaging with Faye : ReferenceError: Faye is not defined)

我在我的Rails应用程序中使用Faye websockets,就像Railcasts#260一样。一切都很好,但现在我得到的错误就像

ReferenceError:未定义Faye

这里

$(function() {
    var faye = new Faye.Client('http://localhost:9292/faye');
    faye.subscribe("/games/messages/new", function(data) {
        eval(data)
    });
});

我开始了我的faye: rackup faye.ru -s thin -E production

faye.ru

require 'faye'
Faye::WebSocket.load_adapter('thin')
faye_server = Faye::RackAdapter.new(:mount => '/faye', :timeout => 45)
run faye_server

我不知道发生了什么,我唯一改变的是安装rails-unicorn gem并默认启动它。

更新: http:// localhost:9292 /说:

当然你不是在寻找/ faye?

如果我添加/ faye -

错误的请求。

如果我添加/faye.js -

fs的js剧本

更新:对于现在它只是工作,不知道为什么,但它是。 谢谢你们。


I am using Faye websockets in my Rails application, just like Railcasts # 260. All was fine, but now I am getting error like

ReferenceError: Faye is not defined

here

$(function() {
    var faye = new Faye.Client('http://localhost:9292/faye');
    faye.subscribe("/games/messages/new", function(data) {
        eval(data)
    });
});

I started my faye like: rackup faye.ru -s thin -E production

faye.ru

require 'faye'
Faye::WebSocket.load_adapter('thin')
faye_server = Faye::RackAdapter.new(:mount => '/faye', :timeout => 45)
run faye_server

I don't know what's going on, the only thing I changed was install rails-unicorn gem and default booting from it.

UPDATE: http://localhost:9292/ says:

Sure you're not looking for /faye ?

And if I add /faye -

Bad request.

And if I add /faye.js -

js script of Faye

UPDATED: For a now it just works, don't know why, but it is. Thank you, all.


原文:https://stackoverflow.com/questions/28010609
更新时间:2022-12-04 17:12

最满意答案

测试执行流程 (重点添加):

对于每个类,测试从运行类安装方法开始。 对于每个测试方法, 分配一个新的类实例并执行其实例设置方法。 之后它运行测试方法,然后运行实例拆解方法。 该序列重复了该类中的所有测试方法。 在运行了类中的最后一个测试方法后,Xcode执行类拆解方法并继续下一个类。 重复此序列,直到所有测试类中的所有测试方法都已运行。

在您的情况下, test_B_fooIsNotNil()在新实例上执行,其foo属性为nil

可以将常用设置代码放入setUp()类方法或setUp()实例方法,请参阅了解测试方法的设置和拆解


From Flow of Test Execution (emphasis added):

For each class, testing starts by running the class setup method. For each test method, a new instance of the class is allocated and its instance setup method executed. After that it runs the test method, and after that the instance teardown method. This sequence repeats for all the test methods in the class. After the last test method teardown in the class has been run, Xcode executes the class teardown method and moves on to the next class. This sequence repeats until all the test methods in all test classes have been run.

In your case, test_B_fooIsNotNil() is executed on a fresh instance, for which the foo property is nil.

Common setup code can be put into the setUp() class method or setUp() instance method, see Understanding Setup and Teardown for Test Methods

相关问答

更多
  • 如果我理解你的问题,问题是你在if范围内创建了类的实例。 稍后你试着调用对象thomas的方法eatfood但是当前范围内不存在该对象。 也许你想这样做...... if (outputtype2) { cats thomas(outputtype1); thomas.eatfood(whiskers); } 或者使用指针...... Cats* thomas = NULL; if (outputtype2) { thomas = new Cats(outputtype1); } if ( ...
  • 写@age直接访问实例变量@age 。 写self.age告诉对象发送自己的消息age ,通常返回实例变量@age - 但是可以根据在一个给定的子类中如何实现age方法来做任何其他的事情。 例如,您可能有一个MiddleAgedSocialite类,总是报告其年龄比实际年龄小10岁。 或者更实际上,PersistentPerson类可能会从持久存储器中懒惰地读取该数据,并以哈希方式缓存其所有持久数据。 Writing @age directly accesses the instance variable ...
  • 从测试执行流程 (重点添加): 对于每个类,测试从运行类安装方法开始。 对于每个测试方法, 分配一个新的类实例并执行其实例设置方法。 之后它运行测试方法,然后运行实例拆解方法。 该序列重复了该类中的所有测试方法。 在运行了类中的最后一个测试方法后,Xcode执行类拆解方法并继续下一个类。 重复此序列,直到所有测试类中的所有测试方法都已运行。 在您的情况下, test_B_fooIsNotNil()在新实例上执行,其foo属性为nil 。 可以将常用设置代码放入setUp()类方法或setUp()实例方法,请 ...
  • 我如何使$ c3和$ c4是可选的,所以当没有任何东西可以匹配时,正则表达式不会失败? 除非你必须使用个体变量,否则考虑使用一个数组来保存你想要的字符: use strict; use warnings; my @a = ( "a b", "a b c", "a b c d" ); for my $line (@a) { my @chars = split ' ', $line; #my @chars = $line =~ /\S+/g; # Or use this regex to c ...
  • 您根本不必在头文件中声明它们。 实例变量和属性通常在实现文件的私有类别中添加: @interface MyClass () { BOOL _someVar; } @property NSString *someOtherVar; - (void)_aPrivateMethod:(id)something; @end @implementation MyClass ... @end You don't have to declare them in the header file at al ...
  • 我的第一直觉是告诉你不要使用instance_variable_set除非你真的知道你正在使用它。 它本质上是元编程的工具,或者是绕过实例变量可见性的黑客。 也就是说,如果该变量没有setter,则无论如何都可以使用instance_variable_set进行设置。 如果你控制代码只是创建一个setter,那就好多了。 尝试查看绝大多数实例变量设置需求的访问器。 它们是一种惯用的方法,可以“免费”为实例变量设置getter和setter,而无需编写这些函数。 如果你确实需要instance_variabl ...
  • 根据错误,您的方法的返回类型是Response 。 但是, update(resourceID, data).map(updatedResource -> Response.status(Response.Status.OK).entity(updatedResource).build())返回一个Optional ,因此您必须将返回类型更改为Optional 。 所以方法看起来像这样: public Optional yourMethod (...) { ...
  • 有了这个 var john: Person? Stack顶部添加了一个内存插槽。 此插槽的类型是Person类型的Optional值 Optional 在这个内存位置,我们找到了Optional.none值。 在这之后 john = Person(name: "Mr Robot") 一些内存被分配到Heap 。 然后按照Person initializer的逻辑写入该内存。 然后让我们回到堆栈。 这里Optional.none替换为值Optional.some , Person对象的地 ...
  • 你的NSMutableArray没有问题。 var arr = NSMutableArray() 创建一个非可选的数组实例。 到目前为止,这么好......表达 NSMutableArray(contentsOfFile: plistfinalpath) 可以返回nil,因此返回可选值。 在这里,您尝试创建另一个NSMutableArray实例,并将结果分配给var arr。 包含指定aPath的文件内容的可变数组。 如果无法打开文件或者无法将文件内容解析为可变数组,则返回nil。 对你来说,最好的方法 ...
  • 从文档( https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/BasicOperators.html ) 如果a包含值,则nil-coalescing运算符(a ?? b)展开可选a;如果a为n,则返回默认值b。 表达式a始终是可选类型。 表达式b必须与存储在a中的类型匹配。 在这种情况下,如果row.section为nil,则整个表达式(row.secti ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)