Class: Rubocop::Cop::ActiveRecordSerialize

Inherits:
RuboCop::Cop::Base
  • Object
show all
Defined in:
lib/rubocop/cop/active_record_serialize.rb

Overview

Cop that prevents the use of ‘serialize` in ActiveRecord models.

Examples:

# bad
serialize :preferences

# good
# Column for each individual preference

Constant Summary collapse

MSG =
'Do not store serialized data in the database, use separate columns and/or tables instead'
RESTRICT_ON_SEND =
%i[serialize].freeze

Instance Method Summary collapse

Instance Method Details

#on_send(node) ⇒ Object



18
19
20
21
22
# File 'lib/rubocop/cop/active_record_serialize.rb', line 18

def on_send(node)
  return if node.receiver

  add_offense(node.loc.selector)
end