You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Move the "physical workshop needs a host" validation onto Workshop #2939
Admin::WorkshopsController enforces the rule "a physical workshop must have a host" in the controller (workshop_type_valid? plus physical_workshop_and_no_host?), adding a validation error from the controller:
defworkshop_type_valid?returntrueunlessphysical_workshop_and_no_host?(@workshop)@workshop.errors.add(:host,"can't be blank")falseend
Validation rules belong on the model so create, update, and any future caller get them for free.
Proposed change
Move the rule into a Workshop validation, reusing the controller's intent and error message (host "can't be blank").
Delete workshop_type_valid? and physical_workshop_and_no_host? from the controller; the create/update flows keep their existing flash behaviour via @workshop.errors.
Acceptance
Creating/updating a physical workshop without a host fails with the same error message as today.
Model specs cover the new validation; existing admin workshop controller specs pass.
Activity