diff options
author | Tsukuru Tanimichi <info+git@ttanimichi.com> | 2017-06-26 13:01:54 +0900 |
---|---|---|
committer | Tsukuru Tanimichi <info+git@ttanimichi.com> | 2017-06-26 13:01:54 +0900 |
commit | f9c43f252586a8d70687e23ae450e52f14e855a1 (patch) | |
tree | f7efe6f1a5d7fcbbcfe8e4ed79bcd85bafd845a2 /railties/lib | |
parent | 98d12f1ef31014287c897fc60df4e1af70781ca3 (diff) | |
download | rails-f9c43f252586a8d70687e23ae450e52f14e855a1.tar.gz rails-f9c43f252586a8d70687e23ae450e52f14e855a1.tar.bz2 rails-f9c43f252586a8d70687e23ae450e52f14e855a1.zip |
Add `railtie.rb` to the plugin generator
Diffstat (limited to 'railties/lib')
3 files changed, 14 insertions, 2 deletions
diff --git a/railties/lib/rails/generators/rails/plugin/plugin_generator.rb b/railties/lib/rails/generators/rails/plugin/plugin_generator.rb index 118e44d9d0..445235852d 100644 --- a/railties/lib/rails/generators/rails/plugin/plugin_generator.rb +++ b/railties/lib/rails/generators/rails/plugin/plugin_generator.rb @@ -60,7 +60,12 @@ module Rails template "lib/%namespaced_name%.rb" template "lib/tasks/%namespaced_name%_tasks.rake" template "lib/%namespaced_name%/version.rb" - template "lib/%namespaced_name%/engine.rb" if engine? + + if engine? + template "lib/%namespaced_name%/engine.rb" + else + template "lib/%namespaced_name%/railtie.rb" + end end def config diff --git a/railties/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%.rb b/railties/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%.rb index 40b1c4cee7..3285055eb7 100644 --- a/railties/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%.rb +++ b/railties/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%.rb @@ -1,5 +1,7 @@ <% if engine? -%> require "<%= namespaced_name %>/engine" - +<% else -%> +require "<%= namespaced_name %>/railtie" <% end -%> + <%= wrap_in_modules "# Your code goes here..." %> diff --git a/railties/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%/railtie.rb b/railties/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%/railtie.rb new file mode 100644 index 0000000000..7bdf4ee5fb --- /dev/null +++ b/railties/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%/railtie.rb @@ -0,0 +1,5 @@ +<%= wrap_in_modules <<-rb.strip_heredoc + class Railtie < ::Rails::Railtie + end +rb +%> |