Skip to content

Commit bf2ce9c

Browse files
committed
Prioritize custom view templates
1 parent 781d840 commit bf2ce9c

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lib/generators/tailwindcss/scaffold/scaffold_generator.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,16 @@ module Generators
66
class ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
77
include Rails::Generators::ResourceHelpers
88

9-
source_root File.expand_path("../templates", __FILE__)
9+
10+
def self.source_root
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
18+
end
1019

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

0 commit comments

Comments
 (0)