@@ -93,11 +93,7 @@ def rails_new
9393 end
9494
9595 def rails_new_command
96- if ruby_gt_4_0?
97- "rails new #{ fs . project_directory } --database=#{ database . adapter_name } --skip-bundle --skip-javascript --no-rc --skip-bootsnap"
98- else
99- "bundle exec rails new #{ fs . project_directory } --database=#{ database . adapter_name } --skip-bundle --skip-javascript --no-rc --skip-bootsnap"
100- end
96+ "#{ additional_command } rails new #{ fs . project_directory } --database=#{ database . adapter_name } --skip-bundle --skip-javascript --no-rc --skip-bootsnap"
10197 end
10298
10399 def fix_available_locales_warning
@@ -150,21 +146,13 @@ class DevelopmentRecord < ActiveRecord::Base
150146
151147 def add_action_text_migration
152148 fs . within_project do
153- if ruby_gt_4_0?
154- run_command! 'rake action_text:install:migrations'
155- else
156- run_command! 'bundle exec rake action_text:install:migrations'
157- end
149+ run_command! "#{ additional_command } rake action_text:install:migrations"
158150 end
159151 end
160152
161153 def add_active_storage_migration
162154 fs . within_project do
163- if ruby_gt_4_0?
164- run_command! 'rake active_storage:install:migrations'
165- else
166- run_command! 'bundle exec rake active_storage:install:migrations'
167- end
155+ run_command! "#{ additional_command } rake active_storage:install:migrations"
168156 end
169157 end
170158
@@ -182,28 +170,15 @@ def load_environment
182170 end
183171
184172 def run_migrations
185- if ruby_gt_4_0?
186- fs . within_project do
187- run_command! 'rake db:drop:all'
188- run_command! 'rake db:create RAILS_ENV=test'
189- run_command! 'rake db:create RAILS_ENV=development'
190- run_command! 'rake db:create RAILS_ENV=production'
191- end
192-
193- fs . within_project do
194- run_command! 'rake db:migrate'
195- end
196- else
197- fs . within_project do
198- run_command! 'bundle exec rake db:drop:all'
199- run_command! 'bundle exec rake db:create RAILS_ENV=test'
200- run_command! 'bundle exec rake db:create RAILS_ENV=development'
201- run_command! 'bundle exec rake db:create RAILS_ENV=production'
202- end
203-
204- fs . within_project do
205- run_command! 'bundle exec rake db:migrate'
206- end
173+ fs . within_project do
174+ run_command! "#{ additional_command } rake db:drop:all"
175+ run_command! "#{ additional_command } rake db:create RAILS_ENV=test"
176+ run_command! "#{ additional_command } rake db:create RAILS_ENV=development"
177+ run_command! "#{ additional_command } rake db:create RAILS_ENV=production"
178+ end
179+
180+ fs . within_project do
181+ run_command! "#{ additional_command } rake db:migrate"
207182 end
208183 end
209184
@@ -225,5 +200,11 @@ def run_command!(*args)
225200 def rails_version
226201 bundle . version_of ( 'rails' )
227202 end
203+
204+ def additional_command
205+ unless ruby_gt_4_0?
206+ 'bundle exec'
207+ end
208+ end
228209 end
229210end
0 commit comments