Fix TextMate Code Completion for Rails 4+ Models
You might have noticed that after switching to Rails 4 or 5, a lot of code completions and snippets stopped working. No longer can you type bt
hit tab and it expands to belongs_to :object, :class_name => "Object", :foreign_key => "object_id"
.
Rails generators now create models with the ApplicationRecord base class instead of ActiveRecord::Base. TextMate needed ActiveRecord::Base to recognize the document as a Rails model. Since that's not there anymore, the snippets and shortcuts that depend on that scope aren't fired.
Fixing it take 30 seconds:
- Visit Bundle > Edit Bundles in the menu.
- Select Ruby on Rails > Language Grammars > Ruby on Rails.
- Select the editor window that appears and use Find to search for
meta.rails.model
. A couple of lines below that, you'll findActiveRecord::Base
. Change that to[ActiveRecord::Base|ApplicationRecord]
- Save it, and get back to doing great work.
Written by Dave Gerton
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#