Skip to content

Commit ff07593

Browse files
committed
Change Rails/ApplicationRecord to ignore migrations
1 parent b59cecf commit ff07593

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* [#1342](https://github.com/rubocop/rubocop-rails/issues/1342): Change `Rails/ApplicationRecord` to ignore migrations. ([@fatkodima][])

config/default.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,9 @@ Rails/ApplicationRecord:
212212
Enabled: true
213213
SafeAutoCorrect: false
214214
VersionAdded: '0.49'
215-
VersionChanged: '2.5'
215+
VersionChanged: '<<next>>'
216+
Exclude:
217+
- db/**/*.rb
216218

217219
Rails/ArelStar:
218220
Description: 'Enforces `Arel.star` instead of `"*"` for expanded columns.'

lib/rubocop/cop/rails/application_record.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ module Cop
55
module Rails
66
# Checks that models subclass `ApplicationRecord` with Rails 5.0.
77
#
8+
# It is a common practice to define models inside migrations in order to retain forward
9+
# compatibility by avoiding loading any application code. And so migration files are excluded
10+
# by default for this cop.
11+
#
812
# @safety
913
# This cop's autocorrection is unsafe because it may let the logic from `ApplicationRecord`
1014
# sneak into an Active Record model that is not purposed to inherit logic common among other

0 commit comments

Comments
 (0)