If your TextMate is:
- using the Ruby Bundle for files that are Ruby on Rails;
- using the Ruby on Rails Bundle for files that are Rspec;
- any other wrong association.
There are some ways to fix. I followed these steps to fix it:
1. Remove the manual associations. When you use the popup bar at the status bar, in Textmate, you may not know but you are associating files to Bundles, manually, which is bad. To fix it, let’s first read what’s already in there. Run this command in the Terminal:
defaults read com.macromates.textmate OakLanguageFileBindings
Check the manual associations you’ve made so far. And remove them all with:
defaults delete com.macromates.textmate OakLanguageFileBindings
2. Specify inside a Bundle, which files it should be used for. Open Bundles → Bundle Editor → Edit Languages… and locate the Ruby Grammar. Inside this text area, locate a line that looks like this:
fileTypes = ( 'rb', 'rbx', 'rjs', 'Rakefile', 'rake', 'cgi', 'fcgi', 'gemspec', 'irbrc', 'capfile' );
Remove the rb extension. And add it to the Ruby on Rails grammar instead. At the end my lines became like this:
# my Ruby Language grammar fileTypes = ( 'rbx', 'rjs', 'Rakefile', 'rake', 'cgi', 'fcgi', 'gemspec', 'irbrc', 'capfile' ); # my Ruby on Rails Language grammar fileTypes = ( 'rb', 'rxml', 'builder' );
As you see, the rb extension now belongs to the Rails Language Grammar.
Now whenever I open a *.rb file, the Bundle is Ruby on Rails. Whenever I open a *_spec.rb file, the Bundle is RSpec. You can always improve on that idea, and do what you think it’s best for you. For example, you can edit Ruby on Rails grammar for .erb files, .rjs, and the like.
Further information in the TextMate Blog’s post File Type Detection (RSpec & Rails).