diff options
author | Eileen M. Uchitelle <eileencodes@gmail.com> | 2016-04-09 09:46:37 -0400 |
---|---|---|
committer | Eileen M. Uchitelle <eileencodes@gmail.com> | 2016-04-09 09:46:37 -0400 |
commit | e88d63e6f7a7e9a73484ea30859bf3b75a4b7188 (patch) | |
tree | 7790998f8ae4f26a95cd231090fd417ea6f13a9e /activejob/lib | |
parent | f0f16f72e3d053f52bc8a88e1d3181c5c3010622 (diff) | |
parent | 9a9fc01af08b5095de5b6f4f74ffd9dea7759500 (diff) | |
download | rails-e88d63e6f7a7e9a73484ea30859bf3b75a4b7188.tar.gz rails-e88d63e6f7a7e9a73484ea30859bf3b75a4b7188.tar.bz2 rails-e88d63e6f7a7e9a73484ea30859bf3b75a4b7188.zip |
Merge pull request #24165 from y-yagi/generate_application_job_when_not_exist
generate ApplicationJob if it does not already exist
Diffstat (limited to 'activejob/lib')
-rw-r--r-- | activejob/lib/rails/generators/job/job_generator.rb | 15 | ||||
-rw-r--r-- | activejob/lib/rails/generators/job/templates/application_job.rb | 4 |
2 files changed, 19 insertions, 0 deletions
diff --git a/activejob/lib/rails/generators/job/job_generator.rb b/activejob/lib/rails/generators/job/job_generator.rb index 2115fb9f71..6e43e4a269 100644 --- a/activejob/lib/rails/generators/job/job_generator.rb +++ b/activejob/lib/rails/generators/job/job_generator.rb @@ -17,7 +17,22 @@ module Rails # :nodoc: def create_job_file template 'job.rb', File.join('app/jobs', class_path, "#{file_name}_job.rb") + + in_root do + if self.behavior == :invoke && !File.exist?(application_job_file_name) + template 'application_job.rb', application_job_file_name + end + end end + + private + def application_job_file_name + @application_job_file_name ||= if mountable_engine? + "app/jobs/#{namespaced_path}/application_job.rb" + else + 'app/jobs/application_job.rb' + end + end end end end diff --git a/activejob/lib/rails/generators/job/templates/application_job.rb b/activejob/lib/rails/generators/job/templates/application_job.rb new file mode 100644 index 0000000000..0b113b950e --- /dev/null +++ b/activejob/lib/rails/generators/job/templates/application_job.rb @@ -0,0 +1,4 @@ +<% module_namespacing do -%> +class ApplicationJob < ActiveJob::Base +end +<% end -%> |