Skip to content

Commit 39f1847

Browse files
committed
Ensure MavisCLI.load_rails is called
A number of new CLI commands have been added recently, but I forgot to add `MavisCLI.load_rails` meaning when run in a deployment environment they don't have access to any of the models or other classes autoloaded by Rails.
1 parent d2dedc5 commit 39f1847

5 files changed

Lines changed: 10 additions & 0 deletions

File tree

app/lib/mavis_cli/clinics/add_to_organisation.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ class AddToOrganisation < Dry::CLI::Command
1515
desc: "The ODS codes of the clinics"
1616

1717
def call(organisation_ods_code:, team:, clinic_ods_codes:, **)
18+
MavisCLI.load_rails
19+
1820
organisation = Organisation.find_by(ods_code: organisation_ods_code)
1921

2022
if organisation.nil?

app/lib/mavis_cli/clinics/create.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ def call(
2323
address_postcode:,
2424
**
2525
)
26+
MavisCLI.load_rails
27+
2628
Location.create!(
2729
type: :community_clinic,
2830
name:,

app/lib/mavis_cli/schools/add_programme_year_group.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ class AddProgrammeYearGroup < Dry::CLI::Command
1515
desc: "The year groups to add"
1616

1717
def call(urn:, programme_type:, year_groups:, **)
18+
MavisCLI.load_rails
19+
1820
location = Location.school.find_by(urn:)
1921

2022
if location.nil?

app/lib/mavis_cli/schools/add_to_organisation.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ class AddToOrganisation < Dry::CLI::Command
1919
desc: "The programmes administered at the school"
2020

2121
def call(ods_code:, team:, urns:, programmes: [], **)
22+
MavisCLI.load_rails
23+
2224
organisation = Organisation.find_by(ods_code:)
2325

2426
if organisation.nil?

app/lib/mavis_cli/schools/remove_programme_year_group.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ class RemoveProgrammeYearGroup < Dry::CLI::Command
1515
desc: "The year groups to remove"
1616

1717
def call(urn:, programme_type:, year_groups:, **)
18+
MavisCLI.load_rails
19+
1820
location = Location.school.find_by(urn:)
1921

2022
if location.nil?

0 commit comments

Comments
 (0)