Skip to content

Commit 53357ea

Browse files
committed
check if Rails.root was initialized
1 parent 42c78e3 commit 53357ea

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lib/generators/tailwindcss/scaffold/scaffold_generator.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,15 @@ module Generators
66
class ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
77
include Rails::Generators::ResourceHelpers
88

9+
910
def self.source_root
10-
custom_scaffold_templates_path = Rails.root.join("lib", "templates", "erb", "scaffold")
11-
return Dir.exist?(custom_scaffold_templates_path)? custom_scaffold_templates_path : File.expand_path("../templates", __FILE__)
11+
fallback_path=File.expand_path("../templates", __FILE__)
12+
if Rails.root.nil?
13+
return fallback_path
14+
else
15+
custom_scaffold_templates_path = File.join(Rails.root,"lib", "templates", "erb", "scaffold")
16+
return Dir.exist?(custom_scaffold_templates_path)? custom_scaffold_templates_path : fallback_path
17+
end
1218
end
1319

1420
argument :attributes, type: :array, default: [], banner: "field:type field:type"

0 commit comments

Comments
 (0)