Can't get Rubymine to recognize .rb file as Ruby

Completed

I created a controller file by hand in Rubymine named businesses_controller.rb. While creating the file, I created it as a text file, and not a Ruby file. I also did not use any of the generators to create this controller.

Syntax highlighting did not work, so I deleted that file and recreated it using the controller generator. Unfortunately, the file still shows up as a text file, and since Rubymine does not recognize it as a Ruby file, autocompletion does not work for this controller either.

I tried Invalidating Caches, and Reloading from Disk but unfortunately that didn't work. I also removed the entire directory, and downloaded a fresh copy from our subversion project, and tried creating the controller again in a completely separate directory. But Rubymine still did not recognize it as a Ruby file.

Also tried creating a completely new project from scratch with a controller named businesses_controller.rb and it still showed up as a text file. I think this particular filename has been permanently cached somewhere as a non-Ruby file. Is there some other configuration that we are supposed to clear besides invalidating caches, or reloading from disk? Could this be a bug? My version of Rubymine is 3.1.1, Build RM# 103.260 running on OSX (Snow Leopard).

16 comments
Comment actions Permalink

Please ignore this post. It was a user error. Somehow the pattern businesses_controller.rb explicitly got registered as a text file. Removed that and it works great. Thanks!

1
Comment actions Permalink

Thanks for updating the post, develop with pleasure!

Regards,
Oleg

0
Comment actions Permalink
I realise this is an old thread, however 2 years on I also have exactly this problem, where I have created a file as a text file by accident.  I then proceeded to delete this file, and create a new file as a Ruby class, however now Rubymine is only registering this file as a text file.  If I rename the file to any other name it will register correctly as a Ruby file, however it seems this file name is permanently stuck as a text file.

I see your fix "Somehow the pattern businesses_controller.rb explicitly got registered as a text file. Removed that and it works great."... can you please outline how to do this?  Thanks!
0
Comment actions Permalink

Hi,

try File|Settings|File Types.

Regards, Oleg.

2
Comment actions Permalink

Thank you Oleg, you were correct - my file name was under the registered patterns as a text file.

Just a note, I think this is strange Rubymine behaviour; in my opinion it is an unexpected side effect that when creating a new file text file, that the name of that file is registered as a pattern under that file type (in this case, text).  Especially in Ruby where many things are down to convention, most users would have text files as .txt, and ruby files as .rb.  If users want to register more patterns or file names to enforce certain files to be opened as a certain type, I think this should be an explicit action on the users part rather than something happening behind the scenes like this.

0
Comment actions Permalink

Hi,

as far as I remember when you create a new file and RM is unable to decide what type the file should have it asks you to select type.
After that it remember your choice by modifying file types' settings.  So, this is an explicit action.
If you have different experience please describe the scenario in which RM does this implicitly.

Regards, Oleg.

0
Comment actions Permalink

Hi,

I'm experiencing the same problem, but not finding this path: File|Settings|File Types.

Regards,

 

Devan

0
Comment actions Permalink

Found the solution. 

Path for Mac > RubyMine | Preferences | Editor | File Types for macOS 

2
Comment actions Permalink

There must be some sort of keyboard/context menu shortcut to do this, because I just experienced it with a file that has existed for years!

And thanks for the help finding that path in macOS settings @Dmmoylan. I was struggling to find it as well.

0
Comment actions Permalink

Just had the same problem, RubyMine told me to download IntelliJ Ultimate in order to recognize ruby files for the one file lol. 

0
Comment actions Permalink

While working, I received a message to use intellij to recognize my files.  I hit ignore and now my file is lacking syntax highlighting.  If I change the name, the file will regain its type, but if I use the same file name it goes back to being a plain text file.  I've messed around in the file types menu in preferences, but it has no effect.  I've tried all the options when the IntelliJ suggestion comes up and none of them do anything other than bring up the file types menu.   This has been an issue for almost 10 years, how about a fix?

0
Comment actions Permalink

@J Marcus1943, could you please check that this file name pattern isn't registered in Preferences | File Types | Text?

0
Comment actions Permalink

That's exactly what I was looking for in this menu.  Everything appears normal but once the suggestion to use IntelliJ ultimate pops up, the file loses its identity.  Newly created files will work fine, but the file that was open during this popup message becomes useless.  I have created multiple projects and they all have had this happen at some point.

0
Comment actions Permalink

I'm experiencing this same issue. I have performed all of the steps mentioned here. Invalidate Cache/restart, Ensure that *.rb is not in the registered pattern for txt, even deleting the file/project and re creating/cloning. The file icon shows a ruby file, yet there is no syntax highlighting and I can not click to go to definition of method. It doesn't recognize spacing/formatting that is defined for other ruby file either.

0
Comment actions Permalink

Hello Michael,

does it happen in 2019.2? Is it for all Ruby files or only a certain one? Do you have any 3rd party plugins installed? (if so then please try disabling them)

1
Comment actions Permalink

Nope, I was not aware of the 2019.2 update. Just updated and all is well now. Thank you so much :D

0

Please sign in to leave a comment.