Class: RuboCop::Cop::Mavenlint::UseApplicationRecord
- Inherits:
-
Cop
- Object
- Cop
- RuboCop::Cop::Mavenlint::UseApplicationRecord
- Includes:
- EnforceSuperclass
- Defined in:
- lib/rubocop/cop/mavenlint/use_application_record.rb
Overview
Enforce models inheriting from ApplicationRecord instead of ActiveRecord::Base
For example
class SomeModel < ActiveRecord::Base
end
should be
class SomeModel < ApplicationRecord
end
Note that this cop is built in to RuboCop. However, it only runs on Rails 5, and we want run it even though we’re on Rails 4. Once we’re on Rails 5, however, we should be able to remove this custom cop and enable the built-in one.
Constant Summary collapse
- MSG =
'Models should subclass `ApplicationRecord`.'.freeze
- SUPERCLASS =
'ApplicationRecord'.freeze
- BASE_PATTERN =
'(const (const nil? :ActiveRecord) :Base)'.freeze