Module: Hibiki::Rails::Generators::ScaffoldParentNotices

Included in:
ScaffoldControllerGenerator
Defined in:
lib/generators/hibiki/rails/scaffold_parent_notices.rb

Overview

What the generator says about the model a belongs_to points AT.

One line per PARENT file, from the reports ScaffoldParentInjection leaves behind. Split from that module along the report hash, which is the seam it already had: one side decides and writes, this one explains.

What this replaced warned about a missing has_many only when the fields came from an argument list — the one path that cannot look at the parent at all — so it spoke when it did not know and stayed silent when it did.

No extra green inject line here: Thor already prints one per file it touches, and with several belongs_tos a second would bury these.

Constant Summary collapse

PARENT_PIECES =

Each injected piece with its own reason attached, so a parent that needed only one of them is never told about the other.

{
  has_many: "the has_many with a dependent: option — Rails' scaffold writes only the " \
            "belongs_to half, so destroying one raises InvalidForeignKey",
  ping: "the cross-resource after_commit — a row prints this record's label, so a rename " \
        "here repaints nothing without it"
}.freeze