##// END OF EJS Templates
replace RAILS_ROOT to Rails.root at lib/generators/redmine_plugin_model/redmine_plugin_model_generator.rb....
Toshi MARUYAMA -
r5972:37dc9aeac2f8
parent child
Show More
@@ -1,55 +1,55
1 1 require 'rails_generator/base'
2 2 require 'rails_generator/generators/components/controller/controller_generator'
3 3
4 4 class RedminePluginControllerGenerator < ControllerGenerator
5 5 attr_reader :plugin_path, :plugin_name, :plugin_pretty_name
6 6
7 7 def initialize(runtime_args, runtime_options = {})
8 8 runtime_args = runtime_args.dup
9 9 usage if runtime_args.empty?
10 10 @plugin_name = "redmine_" + runtime_args.shift.underscore
11 11 @plugin_pretty_name = plugin_name.titleize
12 12 @plugin_path = "vendor/plugins/#{plugin_name}"
13 13 super(runtime_args, runtime_options)
14 14 end
15 15
16 16 def destination_root
17 File.join(RAILS_ROOT, plugin_path)
17 File.join(Rails.root, plugin_path)
18 18 end
19 19
20 20 def manifest
21 21 record do |m|
22 22 # Check for class naming collisions.
23 23 m.class_collisions class_path, "#{class_name}Controller", "#{class_name}ControllerTest", "#{class_name}Helper"
24 24
25 25 # Controller, helper, views, and test directories.
26 26 m.directory File.join('app/controllers', class_path)
27 27 m.directory File.join('app/helpers', class_path)
28 28 m.directory File.join('app/views', class_path, file_name)
29 29 m.directory File.join('test/functional', class_path)
30 30
31 31 # Controller class, functional test, and helper class.
32 32 m.template 'controller.rb.erb',
33 33 File.join('app/controllers',
34 34 class_path,
35 35 "#{file_name}_controller.rb")
36 36
37 37 m.template 'functional_test.rb.erb',
38 38 File.join('test/functional',
39 39 class_path,
40 40 "#{file_name}_controller_test.rb")
41 41
42 42 m.template 'helper.rb.erb',
43 43 File.join('app/helpers',
44 44 class_path,
45 45 "#{file_name}_helper.rb")
46 46
47 47 # View template for each action.
48 48 actions.each do |action|
49 49 path = File.join('app/views', class_path, file_name, "#{action}.html.erb")
50 50 m.template 'view.html.erb', path,
51 51 :assigns => { :action => action, :path => path }
52 52 end
53 53 end
54 54 end
55 55 end
General Comments 0
You need to be logged in to leave comments. Login now