简体   繁体   English

Rubymine:Ctrl +单击不起作用

[英]Rubymine: Ctrl + Click not working

Recently I have updated my Rails and Ruby(1.9.3 to 2.1) version, using a newer version of RailsInstaller After that, in RubyMine , when I use ctrl + click to jump from code to code, sometimes it's not working. 最近,我使用新版本的RailsInstaller更新了Rails和Ruby(1.9.3至2.1)版本。此后,在RubyMine ,当我使用ctrl + click从代码跳转到代码时,有时无法正常工作。

CASE1 情况1

I have included some constants in initializers/resources_constants.rb , So I can use them like constants = RESOURCES_CONSTANT::SOME_CONSTANT . 我在initializers/resources_constants.rb包含了一些常量,因此我可以像constants = RESOURCES_CONSTANT::SOME_CONSTANT一样使用它们。

It used to work fine. 过去工作正常。 When ctrl + click , I can jump directly into the resources_constants.rb . ctrl + click ,我可以直接跳到resources_constants.rb But now, I can not switch to it. 但是现在,我无法切换到它。

The code itself is still running very well, and I can still use the constants defined in that file. 代码本身仍然运行良好,我仍然可以使用该文件中定义的常量。

CASE2 CASE2

require 'nokogiri' works fine, I can jump to it. require 'nokogiri'可以正常工作,我可以跳到它。

CASE3 CASE3

video.get_hits . video.get_hits It's a instance method defined in Video.rb model. 这是Video.rb模型中定义的实例方法。 I cannot jump to it, but the code still works fine. 我不能跳到它,但是代码仍然可以正常工作。

I faced the same problem few months earlier after updating the Rubymine. 在更新Rubymine之后的几个月,我遇到了同样的问题。 I contacted their support and it was resolved by: 我联系了他们的支持,并通过以下方式解决了该问题:

Clicking on File --> Invalidate Caches / Restart 单击文件->使缓存无效/重新启动
It will invalidate your cache build in previous version and index it as per new. 它将使您的高速缓存版本无效,并按照新版本对其进行索引。

This is kinda the Jetbrains "nuclear option", but it's worked for me every time this type of thing happens (usually after ruby version updates). 这有点像Jetbrains的“核选项”,但是每次这种事情发生时(通常是在红宝石版本更新之后),它对我来说都是有用的。

  1. Completely close all running instances of RubyMine 完全关闭所有正在运行的RubyMine实例
  2. In the root directory of the project in question, delete the hidden .idea directory 在相关项目的根目录中,删除隐藏的.idea目录
  3. Reopen your project in RubyMine as normal 照常在RubyMine中重新打开您的项目

Hi seeing any rubyfile name resources_constants.rb I guess it has a class named ResourcesConstants so any contant defined in that class is SOME_CONSTANT = 'some value' 嗨,看到任何rubyfile名称resources_constants.rb我猜它有一个名为ResourcesConstants的类,因此该类中定义的任何SOME_CONSTANT = 'some value'SOME_CONSTANT = 'some value'
To access that constant we need to use namespacing operator(::) like 要访问该常量,我们需要使用命名空间operator(::)

ResourcesConstants::SOME_CONSTANT

now your ctrl+click might work. 现在您的ctrl+click可能会起作用。 and I suggest you to restart the server everytime you modify any config files or constants files 我建议您每次修改任何配置文件或常量文件时都重新启动服务器

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM