RubyMine 中未解决的 ruby 引用
有没有办法避免 RubyMine IDE 中出现“未解析的 ruby 引用”警告? 例如,当我视图中的某些代码调用视图助手的方法时,即使代码有效,我也会收到“未解析的 ruby 引用”警告。
上述案例只是众多案例之一。 另一个例子是使用 RSpec 时:
it "should require an email" do
no_email_user = User.new(@attr.merge(:email => ""))
no_email_user.should_not be_valid
end
RubyMine IDE 不知道参数“be_valid”。
我的问题是 - 有什么办法可以解决这个问题吗?我应该需要额外的文件吗?我应该做点不同的事情吗? 那些关于未解析的 ruby 方法/常量的误报确实令人不安,并且它还会影响 RubyMine 中“查找用法”操作的结果。
我正在使用 RubyMine 3.1 我非常感谢您为解决此问题提供的任何帮助。
Is there any way to avoid the "unresolved ruby reference" warning in RubyMine IDE?
for example, when some code in my view calls a method of the view helper, I get the "unresolved ruby reference" warning even though the code works.
The case described above is just one of many.
Another example is when using RSpec:
it "should require an email" do
no_email_user = User.new(@attr.merge(:email => ""))
no_email_user.should_not be_valid
end
the parameter "be_valid" is not known to the RubyMine IDE.
My question is - is there any way to solve this? should I require additional files? should I do something differently?
Those false positives regarding unresolved ruby methods/constants are really disturbing, and it also affects the results of the "find usages" action in RubyMine.
I'm using RubyMine 3.1
I would really appreciate any help in resolving this issue.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
此问题已提交到 RubyMine 错误跟踪器,请观看/投票。
This issue is already submitted to the RubyMine bug tracker, please watch/vote.
我想,在这种情况下,这个问题是很难解决的。 Ruby 使用
method_missing
可以实现伟大的魔法,据我所知,be_valid
也是通过这种方式实现的。实际上没有be_valid
但它调用valid?
方法并期望它为 true。在 rspec 中,这适用于任何以
?
结尾的方法。因此,如果您有一个方法ready?
,您可以编写should be_ready
。我是 Rubymine 的全职用户,但我不知道他们如何解决这个问题,我也不期待它。
I think in this case this is hard to solve. Ruby allows great magic to happen using
method_missing
and as far as i know, thebe_valid
is also implemented in this way. Actually there is nobe_valid
but it calls thevalid?
method and expects it to be true.In rspec, this work for any method ending in a
?
. So if you have a methodready?
, you can writeshould be_ready
.I am a fulltime Rubymine user, but i do not know how they could solve that nor do i expect it.
要关闭您在 RubyMine 3.1 中收到的警告(我认为这可能是您最初的问题),您需要转到“文件”->“首选项”。然后,转到左侧的“检查”。打开“Ruby”部分并取消选中“Unresolved Ruby Reference”。首选项是可搜索的,因此,如果您遇到类似的情况,您可以尝试搜索。祝你好运!
To turn off the warning you are getting in RubyMine 3.1, which I think might be your original question, you need to go to File->Preferences. Then, on the left, go to "Inspections". Open up the "Ruby" section and uncheck "Unresolved Ruby Reference." The Preferences is searchable so, if you get others like that, you might try the search. Good luck!