Skip to content

Commit 1332e42

Browse files
author
David Heinemeier Hansson
committed
Only attempt to add application link tag on Rails versions prior to 8 (closes #161)
1 parent e061000 commit 1332e42

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

lib/install/install.rb

+16-14
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,23 @@
2020
say "Remove app/assets/stylesheets/application.css so build output can take over"
2121
remove_file "app/assets/stylesheets/application.css"
2222

23-
if (app_layout_path = Rails.root.join("app/views/layouts/application.html.erb")).exist?
24-
say "Add stylesheet link tag in application layout"
25-
insert_into_file(
26-
app_layout_path.to_s,
27-
defined?(Turbo) ?
28-
%(\n <%= stylesheet_link_tag "application", "data-turbo-track": "reload" %>) :
29-
%(\n <%= stylesheet_link_tag "application" %>),
30-
before: /\s*<\/head>/
31-
)
32-
else
33-
say "Default application.html.erb is missing!", :red
34-
if defined?(Turbo)
35-
say %( Add <%= stylesheet_link_tag "application", "data-turbo-track": "reload" %> within the <head> tag in your custom layout.)
23+
if Rails::VERSION::MAJOR < 8
24+
if (app_layout_path = Rails.root.join("app/views/layouts/application.html.erb")).exist?
25+
say "Add stylesheet link tag in application layout"
26+
insert_into_file(
27+
app_layout_path.to_s,
28+
defined?(Turbo) ?
29+
%(\n <%= stylesheet_link_tag "application", "data-turbo-track": "reload" %>) :
30+
%(\n <%= stylesheet_link_tag "application" %>),
31+
before: /\s*<\/head>/
32+
)
3633
else
37-
say %( Add <%= stylesheet_link_tag "application" %> within the <head> tag in your custom layout.)
34+
say "Default application.html.erb is missing!", :red
35+
if defined?(Turbo)
36+
say %( Add <%= stylesheet_link_tag "application", "data-turbo-track": "reload" %> within the <head> tag in your custom layout.)
37+
else
38+
say %( Add <%= stylesheet_link_tag "application" %> within the <head> tag in your custom layout.)
39+
end
3840
end
3941
end
4042

0 commit comments

Comments
 (0)