Skip to content

WIP: [Rails5] Add `ApplicationRecord`

blackst0ne requested to merge blackst0ne-rails5-update-models-inheritance into master

What does this MR do?

  1. Adds app/models/application_record.rb abstract file (this is a part of migration from official Rails guide).
  2. Replaces ActiveRecord::Base with ApplicationRecord by rubocop --auto-correct command.
  3. Adds a rubocop's cop with the autocorrection feature that checks for correct constant calls including inheritance.
  4. Adds a spec for the new rubocop's cop.
  5. Change rails' model generator to explicitly set ApplicationRecord as a model parent.

TODO

  • Set --parent ApplicationRecord explicitly before rails' command gets unshifted in rails/commands.
    This step depends on !17828 (merged) as common code is used by both MRs.
  • Fix typos in the spec it blocks (add trailing s).
  • Update EE codebase when this MR is reviewed.

Why was this MR needed?

Migrating to rails 5.0

Does this MR meet the acceptance criteria?

What are the relevant issue numbers?

#14286 (closed) and !12841 (closed)

Edited by blackst0ne

Merge request reports