mdd 3.0.2 → 3.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. data/app/helpers/mdwa_helper.rb +2 -1
  2. data/lib/generators/mdwa/association/association_generator.rb +1 -1
  3. data/lib/generators/mdwa/association/templates/migrate/many_to_many.rb +1 -1
  4. data/lib/generators/mdwa/association/templates/migrate/one_field.rb +2 -1
  5. data/lib/generators/mdwa/code/code_generator.rb +54 -22
  6. data/lib/generators/mdwa/code/templates/migration.rb +2 -1
  7. data/lib/generators/mdwa/entity/entity_generator.rb +1 -2
  8. data/lib/generators/mdwa/entity/templates/entity.rb +2 -1
  9. data/lib/generators/mdwa/from_requirements/from_requirements_generator.rb +56 -0
  10. data/lib/generators/mdwa/process/USAGE +4 -0
  11. data/lib/generators/mdwa/process/process_generator.rb +24 -0
  12. data/lib/generators/mdwa/process/templates/process.rb +49 -0
  13. data/lib/generators/mdwa/requirement/USAGE +4 -0
  14. data/lib/generators/mdwa/requirement/requirement_generator.rb +24 -0
  15. data/lib/generators/mdwa/requirement/templates/requirement.rb +21 -0
  16. data/lib/generators/mdwa/sandbox/sandbox_generator.rb +1 -1
  17. data/lib/generators/mdwa/sandbox/templates/app/assets/stylesheets/mdwa/template/backend.css.erb +2 -2
  18. data/lib/generators/mdwa/sandbox/templates/app/controllers/a/backend_controller.rb +2 -1
  19. data/lib/generators/mdwa/sandbox/templates/app/controllers/a/users/sessions_controller.rb +1 -1
  20. data/lib/generators/mdwa/sandbox/templates/app/controllers/public_controller.rb +1 -0
  21. data/lib/generators/mdwa/sandbox/templates/config/initializers/devise.rb +1 -0
  22. data/lib/generators/mdwa/sandbox/templates/config/initializers/mdwa_layout.rb +2 -1
  23. data/lib/generators/mdwa/sandbox/templates/config/locales/mdwa.en.yml +1 -1
  24. data/lib/generators/mdwa/sandbox/templates/db/migrate/devise_create_users.rb +1 -1
  25. data/lib/generators/mdwa/sandbox/templates/db/seeds.rb +1 -1
  26. data/lib/generators/mdwa/sandbox/templates/db/seeds/site.rb +1 -1
  27. data/lib/generators/mdwa/scaffold/scaffold_generator.rb +10 -3
  28. data/lib/generators/mdwa/scaffold/templates/controllers/ajax_controller.rb +2 -1
  29. data/lib/generators/mdwa/scaffold/templates/controllers/controller.rb +2 -1
  30. data/lib/generators/mdwa/scaffold/templates/db_migrate/migrate.rb +2 -1
  31. data/lib/generators/mdwa/scaffold/templates/models/model.rb +2 -1
  32. data/lib/generators/mdwa/scaffold/templates/models/module.rb +2 -1
  33. data/lib/generators/mdwa/user/templates/user.rb +12 -0
  34. data/lib/generators/mdwa/user/user_generator.rb +13 -104
  35. data/lib/generators/mdwa/{user → user_scaffold}/USAGE +1 -1
  36. data/lib/generators/mdwa/{user → user_scaffold}/templates/controllers/ajax_controller.rb +2 -1
  37. data/lib/generators/mdwa/{user → user_scaffold}/templates/controllers/controller.rb +2 -1
  38. data/lib/generators/mdwa/{user → user_scaffold}/templates/migrate.rb +2 -1
  39. data/lib/generators/mdwa/{user → user_scaffold}/templates/views/update.js.erb +0 -0
  40. data/lib/generators/mdwa/user_scaffold/user_scaffold_generator.rb +139 -0
  41. data/lib/mdd.rb +1 -1
  42. data/lib/mdwa.rb +1 -1
  43. data/lib/mdwa/all.rb +1 -1
  44. data/lib/mdwa/dsl.rb +17 -4
  45. data/lib/mdwa/dsl/action.rb +78 -0
  46. data/lib/mdwa/dsl/entities.rb +4 -4
  47. data/lib/mdwa/dsl/entity.rb +59 -23
  48. data/lib/mdwa/dsl/entity_actions.rb +73 -0
  49. data/lib/mdwa/dsl/entity_association.rb +1 -1
  50. data/lib/mdwa/dsl/entity_attribute.rb +1 -1
  51. data/lib/mdwa/dsl/entity_specification.rb +22 -0
  52. data/lib/mdwa/dsl/process.rb +53 -0
  53. data/lib/mdwa/dsl/process_detail.rb +57 -0
  54. data/lib/mdwa/dsl/process_detail_next_action.rb +16 -0
  55. data/lib/mdwa/dsl/requirement.rb +23 -0
  56. data/lib/mdwa/dsl/requirements.rb +57 -0
  57. data/lib/mdwa/dsl/user.rb +34 -0
  58. data/lib/mdwa/dsl/users.rb +57 -0
  59. data/lib/mdwa/dsl/workflow.rb +57 -0
  60. data/lib/mdwa/generators.rb +1 -1
  61. data/lib/mdwa/generators/model.rb +3 -1
  62. data/lib/mdwa/generators/model_association.rb +4 -1
  63. data/lib/mdwa/generators/model_attribute.rb +2 -1
  64. data/lib/mdwa/layout.rb +1 -1
  65. data/lib/mdwa/layout/base.rb +1 -1
  66. data/lib/mdwa/layout/helper.rb +1 -1
  67. data/lib/mdwa/version.rb +1 -1
  68. data/test/entity_actions_test.rb +101 -0
  69. data/test/entity_specifications_test.rb +37 -0
  70. data/test/entity_test.rb +1 -1
  71. data/test/layout_test.rb +1 -1
  72. data/test/process_test.rb +86 -0
  73. data/test/requirements_test.rb +44 -0
  74. data/test/users_test.rb +55 -0
  75. metadata +37 -10
  76. data/lib/mdwa/dsl/generator.rb +0 -10
  77. data/test/generators_test.rb +0 -0
@@ -1,3 +1,4 @@
1
+ # -*- encoding : utf-8 -*-
1
2
  # Use this hook to configure devise mailer, warden hooks and so forth.
2
3
  # Many of these configuration options can be set straight in your model.
3
4
  Devise.setup do |config|
@@ -1,3 +1,4 @@
1
+ # -*- encoding : utf-8 -*-
1
2
  require 'mdwa/layout'
2
3
  MDWA::Layout::Base.config do |config|
3
4
  config['/*'] = 'public'
@@ -5,4 +6,4 @@ MDWA::Layout::Base.config do |config|
5
6
  config['/a/users/passwords#*'] = 'system'
6
7
  config['/a/users/sessions#new'] = 'login'
7
8
  config['/a/users/sessions#create'] = 'login'
8
- end
9
+ end
@@ -30,7 +30,7 @@ en:
30
30
  index_title: "System users"
31
31
  index_id: "ID"
32
32
  index_name: "Name"
33
- index_email: "Email"
33
+ index_email: "E-mail"
34
34
  index_remove: "Remove?"
35
35
  index_remove_label: "Remove"
36
36
  index_confirm_deletion: "Are you sure?"
@@ -35,4 +35,4 @@ class DeviseCreateUsers < ActiveRecord::Migration
35
35
  add_index :users, :type
36
36
  end
37
37
 
38
- end
38
+ end
@@ -1,2 +1,2 @@
1
1
  # -*- encoding : utf-8 -*-
2
- require File.expand_path( '../seeds/site', __FILE__ )
2
+ require File.expand_path( '../seeds/site', __FILE__ )
@@ -3,4 +3,4 @@ Permission.create( :name => "SuperAdmin" ) if Permission.find_by_name("SuperAdmi
3
3
 
4
4
  if Administrator.count.zero?
5
5
  Administrator.create :name => "Administrator", :email => 'admin@admin.com', :password => 'admin123', :password_confirmation => 'admin123'
6
- end
6
+ end
@@ -1,3 +1,4 @@
1
+ # -*- encoding : utf-8 -*-
1
2
  require 'rails/generators/migration'
2
3
  require 'mdwa/generators'
3
4
 
@@ -108,8 +109,14 @@ module Mdwa
108
109
 
109
110
  def routes
110
111
  unless options.skip_interface
111
- route "resources :#{@model.plural_name}" unless @model.namespace?
112
- route "namespace :#{@model.space} do resources :#{@model.plural_name} end" if @model.namespace?
112
+ route_str = []
113
+ route_str << "namespace :#{@model.space} do" if @model.namespace?
114
+ route_str << "\tcontroller :#{@model.plural_name} do"
115
+ route_str << "\tend"
116
+ route_str << "\tresources :#{@model.plural_name}"
117
+ route_str << "end" if @model.namespace?
118
+
119
+ route route_str.join("\n")
113
120
  end
114
121
  end
115
122
 
@@ -147,4 +154,4 @@ module Mdwa
147
154
  end
148
155
 
149
156
  end
150
- end
157
+ end
@@ -1,3 +1,4 @@
1
+ # -*- encoding : utf-8 -*-
1
2
  class <%= @model.controller_name %>Controller < <%= @inherit_controller || 'ApplicationController' %>
2
3
 
3
4
  load_and_authorize_resource :class => "<%= @model.klass %>"
@@ -70,4 +71,4 @@ class <%= @model.controller_name %>Controller < <%= @inherit_controller || 'Appl
70
71
  @<%= @model.plural_name %> = <%= @model.klass %>.paginate :page => 1
71
72
  end
72
73
 
73
- end
74
+ end
@@ -1,3 +1,4 @@
1
+ # -*- encoding : utf-8 -*-
1
2
  class <%= @model.controller_name %>Controller < <%= @inherit_controller || 'ApplicationController' %>
2
3
 
3
4
  load_and_authorize_resource :class => "<%= @model.klass %>"
@@ -69,4 +70,4 @@ class <%= @model.controller_name %>Controller < <%= @inherit_controller || 'Appl
69
70
  end
70
71
  end
71
72
 
72
- end
73
+ end
@@ -1,3 +1,4 @@
1
+ # -*- encoding : utf-8 -*-
1
2
  class Create<%= @model.plural_name.camelize %> < ActiveRecord::Migration
2
3
 
3
4
  def self.up
@@ -15,4 +16,4 @@ class Create<%= @model.plural_name.camelize %> < ActiveRecord::Migration
15
16
  drop_table :<%= @model.plural_name %>
16
17
  end
17
18
 
18
- end
19
+ end
@@ -1,5 +1,6 @@
1
+ # -*- encoding : utf-8 -*-
1
2
  class <%= @model.klass %> < ActiveRecord::Base
2
3
 
3
4
  attr_accessible <%= @model.simple_attributes.collect {|a| ":" + a.name }.join(', ') %>
4
5
 
5
- end
6
+ end
@@ -1,2 +1,3 @@
1
+ # -*- encoding : utf-8 -*-
1
2
  module <%= @model.namespace %>
2
- end
3
+ end
@@ -0,0 +1,12 @@
1
+ # -*- encoding : utf-8 -*-
2
+ require 'mdwa/dsl'
3
+ MDWA::DSL.users.register '<%= @user %>' do |u|
4
+
5
+ # Description of what this user does in the system.
6
+ # u.description = 'Member of the programmers team.'
7
+
8
+ # User roles
9
+ # By default, the user name is already included by default.
10
+ # u.user_roles = ['<%= @user %>']
11
+
12
+ end
@@ -1,121 +1,30 @@
1
+ # -*- encoding : utf-8 -*-
1
2
  require 'rails/generators/migration'
2
- require 'mdwa/generators'
3
+ require 'mdwa/dsl'
3
4
 
4
5
  module Mdwa
5
-
6
6
  module Generators
7
7
 
8
8
  class UserGenerator < Rails::Generators::Base
9
- include Rails::Generators::Migration
10
9
 
11
10
  source_root File.expand_path('../templates', __FILE__)
12
-
13
- attr_accessor :model, :specific_model
14
11
 
15
- argument :scaffold_name, :type => :string, :banner => "[namespace]/Model"
16
- argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
17
-
18
- class_option :model, :desc => 'Use if model is different than the scaffold name. Format: "[namespace]/Model"', :type => :string
19
- class_option :ajax, :desc => 'Generates modal forms and AJAX submits.', :type => :boolean, :default => false
20
- class_option :skip_rake_migrate, :desc => 'Skips running rake db:migrate', :type => :boolean, :default => false
21
- class_option :skip_timestamp, :desc => 'Skip timestamp generator on migration files.', :type => :boolean, :default => false
22
- class_option :skip_questions, :desc => 'Answer no for all questions by default.', :type => :boolean, :default => false
23
- class_option :skip_interface, :desc => 'Cretes only models, migrations and associations.', :type => :boolean, :default => false
24
- class_option :only_interface, :desc => 'Skips models, associations and migrations.', :type => :boolean, :default => false
12
+ attr_accessor :user
13
+
14
+ argument :user_name
25
15
 
26
16
  def initialize(*args, &block)
27
-
28
17
  super
29
-
30
- @model = MDWA::Generators::Model.new( scaffold_name )
31
-
32
- # model_name is not valid
33
- print_usage unless @model.valid?
34
-
35
- # verifies specific model name
36
- @specific_model = MDWA::Generators::Model.new( options.model ) unless options.model.blank?
37
- if !@specific_model.nil?
38
- if !@specific_model.valid?
39
- print_usage
40
- else
41
- @model.specific_model_name = @specific_model.raw
42
- end
43
- end
44
-
45
- require_all "#{Rails.root}/app/models/user.rb"
46
- @predefined_fields = User.column_names
47
- @predefined_fields << 'password'
48
- @predefined_fields << 'password_confirmation'
49
-
50
- # sets the model attributes
51
- attributes.each do |attribute|
52
- @model.add_attribute MDWA::Generators::ModelAttribute.new( attribute ) unless User.accessible_attributes.to_a.include?( attribute.split(':').first )
53
- end
54
-
55
- generate "mdwa:scaffold #{scaffold_name} name:string email:string password:password password_confirmation:password #{attributes.join(' ')} #{'--force' if options.force} #{'--ajax' if options.ajax} #{"model=#{options.model}" if options.model} #{'--skip_interface' if options.skip_interface} #{'--only_interface' if options.only_interface} #{'--skip_rake_migrate' if options.skip_rake_migrate} #{'--skip_timestamp' if options.skip_timestamp} #{'--skip_questions' if options.skip_questions} --skip-migrations"
56
-
57
- end
58
-
59
- def controller_and_view
60
- unless options.skip_interface
61
- # controllers
62
- @inherit_controller = 'A::BackendController' if @model.space == 'a'
63
- template "controllers/#{'ajax_' if options.ajax}controller.rb", "app/controllers/#{@model.space}/#{@model.plural_name}_controller.rb"
64
-
65
- # views - update only
66
- template 'views/update.js.erb', "app/views/#{@model.space}/#{@model.plural_name}/update.js.erb"
67
- end
68
- end
69
-
70
- def model_and_migration
71
- # model override
72
- gsub_file "app/models/#{@model.space}/#{@model.singular_name}.rb", 'ActiveRecord::Base', 'User'
73
- inject_into_class "app/models/#{@model.space}/#{@model.singular_name}.rb", @model.model_class do
74
- inj = []
75
- inj << "\n\tafter_create :create_#{@model.singular_name}_permission\n"
76
- inj << "\tdef create_#{@model.singular_name}_permission"
77
- inj << "\t\tself.permissions.push Permission.find_by_name('#{@model.singular_name}')"
78
- inj << "\tend"
79
- inj.join("\n")
80
- end
81
18
 
82
- # override model attributes to not allow field duplicity (causing errorss)
83
- @model.attributes = []
84
- attributes.each do |attribute|
85
- @model.add_attribute MDWA::Generators::ModelAttribute.new( attribute ) unless @predefined_fields.include?( attribute.split(':').first )
86
- end
87
- migration_template 'migrate.rb', "db/migrate/add_#{@model.attributes.collect{|a| a.name}.join('_')}_to_users" unless @model.attributes.empty?
88
-
89
- # include type in db:seed
90
- append_file 'db/seeds/site.rb' do
91
- "\n\nPermission.create( :name => '#{@model.singular_name}' ) if Permission.find_by_name('#{@model.singular_name}').nil?"
92
- end
93
- # run rake db:seeds
94
- if yes?('Run rake db:seed to create permission type?')
95
- rake 'db:migrate'
96
- rake 'db:seed'
97
- end
19
+ @user = user_name.singularize.camelize
98
20
  end
99
-
100
-
101
- def run_rake_db_migrate
102
- if !options.skip_rake_migrate and !options.skip_migrations and !options.only_interface
103
- rake('db:migrate') if !options.skip_questions and yes? 'Run rake db:migrate?'
104
- end
21
+
22
+ def generate_user
23
+ template 'user.rb', "#{MDWA::DSL::USERS_PATH}#{@user.underscore}.rb"
24
+ generate "mdwa:entity #{@user} --user"
105
25
  end
106
26
 
107
- private
108
-
109
- # Sets Rails migration timestamp
110
- def self.next_migration_number(dirname) #:nodoc:
111
- if ActiveRecord::Base.timestamped_migrations
112
- Time.now.utc.strftime("%Y%m%d%H%M%S")
113
- else
114
- "%.3d" % (current_migration_number(dirname) + 1)
115
- end
116
- end
117
-
118
- end
27
+ end # class user generator
119
28
 
120
- end
121
- end
29
+ end # generators
30
+ end # mdwa
@@ -1,3 +1,3 @@
1
1
  Generates a loggable user, similar to MDWA Scaffold.
2
2
  USAGE:
3
- rails g mdwa:user birth_date:date
3
+ rails g mdwa:user_scaffold birth_date:date
@@ -1,3 +1,4 @@
1
+ # -*- encoding : utf-8 -*-
1
2
  class <%= @model.controller_name %>Controller < <%= @inherit_controller || 'ApplicationController' %>
2
3
 
3
4
  load_and_authorize_resource :class => "<%= @model.klass %>"
@@ -75,4 +76,4 @@ class <%= @model.controller_name %>Controller < <%= @inherit_controller || 'Appl
75
76
  @<%= @model.plural_name %> = <%= @model.klass %>.paginate :page => 1
76
77
  end
77
78
 
78
- end
79
+ end
@@ -1,3 +1,4 @@
1
+ # -*- encoding : utf-8 -*-
1
2
  class <%= @model.controller_name %>Controller < <%= @inherit_controller || 'ApplicationController' %>
2
3
 
3
4
  load_and_authorize_resource :class => "<%= @model.klass %>"
@@ -74,4 +75,4 @@ class <%= @model.controller_name %>Controller < <%= @inherit_controller || 'Appl
74
75
  end
75
76
  end
76
77
 
77
- end
78
+ end
@@ -1,3 +1,4 @@
1
+ # -*- encoding : utf-8 -*-
1
2
  class Add<%= @model.attributes.collect{|a| a.name.camelize}.join('') %>ToUsers < ActiveRecord::Migration
2
3
 
3
4
  def self.up
@@ -12,4 +13,4 @@ class Add<%= @model.attributes.collect{|a| a.name.camelize}.join('') %>ToUsers <
12
13
  <%- end -%>
13
14
  end
14
15
 
15
- end
16
+ end
@@ -0,0 +1,139 @@
1
+ # -*- encoding : utf-8 -*-
2
+ require 'rails/generators/migration'
3
+ require 'mdwa/generators'
4
+ require 'mdwa/dsl'
5
+
6
+ module Mdwa
7
+
8
+ module Generators
9
+
10
+ class UserScaffoldGenerator < Rails::Generators::Base
11
+ include Rails::Generators::Migration
12
+
13
+ source_root File.expand_path('../templates', __FILE__)
14
+
15
+ attr_accessor :model, :specific_model
16
+
17
+ argument :scaffold_name, :type => :string, :banner => "[namespace]/Model"
18
+ argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
19
+
20
+ class_option :model, :desc => 'Use if model is different than the scaffold name. Format: "[namespace]/Model"', :type => :string
21
+ class_option :ajax, :desc => 'Generates modal forms and AJAX submits.', :type => :boolean, :default => false
22
+ class_option :skip_rake_migrate, :desc => 'Skips running rake db:migrate', :type => :boolean, :default => false
23
+ class_option :skip_timestamp, :desc => 'Skip timestamp generator on migration files.', :type => :boolean, :default => false
24
+ class_option :skip_questions, :desc => 'Answer no for all questions by default.', :type => :boolean, :default => false
25
+ class_option :skip_interface, :desc => 'Cretes only models, migrations and associations.', :type => :boolean, :default => false
26
+ class_option :only_interface, :desc => 'Skips models, associations and migrations.', :type => :boolean, :default => false
27
+
28
+ def initialize(*args, &block)
29
+
30
+ super
31
+
32
+ @model = MDWA::Generators::Model.new( scaffold_name )
33
+
34
+ # model_name is not valid
35
+ print_usage unless @model.valid?
36
+
37
+ # verifies specific model name
38
+ @specific_model = MDWA::Generators::Model.new( options.model ) unless options.model.blank?
39
+ if !@specific_model.nil?
40
+ if !@specific_model.valid?
41
+ print_usage
42
+ else
43
+ @model.specific_model_name = @specific_model.raw
44
+ end
45
+ end
46
+
47
+ require_all "#{Rails.root}/app/models/user.rb"
48
+ @predefined_fields = User.column_names
49
+ @predefined_fields << 'password'
50
+ @predefined_fields << 'password_confirmation'
51
+
52
+ # sets the model attributes
53
+ attributes.each do |attribute|
54
+ @model.add_attribute MDWA::Generators::ModelAttribute.new( attribute ) unless User.accessible_attributes.to_a.include?( attribute.split(':').first )
55
+ end
56
+
57
+ generate "mdwa:scaffold #{scaffold_name} name:string email:string password:password password_confirmation:password #{attributes.join(' ')} #{'--force' if options.force} #{'--ajax' if options.ajax} #{"model=#{options.model}" if options.model} #{'--skip_interface' if options.skip_interface} #{'--only_interface' if options.only_interface} #{'--skip_rake_migrate' if options.skip_rake_migrate} #{'--skip_timestamp' if options.skip_timestamp} #{'--skip_questions' if options.skip_questions} --skip-migrations"
58
+
59
+ end
60
+
61
+ def controller_and_view
62
+ unless options.skip_interface
63
+ # controllers
64
+ @inherit_controller = 'A::BackendController' if @model.space == 'a'
65
+ template "controllers/#{'ajax_' if options.ajax}controller.rb", "app/controllers/#{@model.space}/#{@model.plural_name}_controller.rb"
66
+
67
+ # views - update only
68
+ template 'views/update.js.erb', "app/views/#{@model.space}/#{@model.plural_name}/update.js.erb"
69
+ end
70
+ end
71
+
72
+ def model_override
73
+ # locate the mdwa user to discover the roles
74
+ require_all "#{MDWA::DSL::USERS_PATH}#{@model.singular_name}.rb"
75
+ @mdwa_user = MDWA::DSL.user(@model.name)
76
+ if @mdwa_user.nil?
77
+ @roles = [@model.name]
78
+ else
79
+ @roles = @mdwa_user.user_roles
80
+ end
81
+
82
+ # model override
83
+ gsub_file "app/models/#{@model.space}/#{@model.singular_name}.rb", 'ActiveRecord::Base', 'User'
84
+ inject_into_class "app/models/#{@model.space}/#{@model.singular_name}.rb", @model.model_class do
85
+ inj = []
86
+ @roles.each do |role|
87
+ inj << "\n\n\tafter_create :create_#{role.underscore}_permission\n"
88
+ inj << "\tdef create_#{role.underscore}_permission"
89
+ inj << "\t\t#{role.underscore}_permission = Permission.find_by_name('#{role.underscore}')"
90
+ inj << "\t\t#{role.underscore}_permission = Permission.create(:name => '#{role.underscore}') if #{role.underscore}_permission.nil?"
91
+ inj << "\t\tself.permissions.push #{role.underscore}_permission"
92
+ inj << "\tend"
93
+ end
94
+ inj.join("\n")
95
+ end
96
+ end
97
+
98
+ def migration_override
99
+
100
+ # override model attributes to not allow field duplicity (causing errors)
101
+ @model.attributes = []
102
+ attributes.each do |attribute|
103
+ @model.add_attribute MDWA::Generators::ModelAttribute.new( attribute ) unless @predefined_fields.include?( attribute.split(':').first )
104
+ end
105
+ migration_template 'migrate.rb', "db/migrate/add_#{@model.attributes.collect{|a| a.name}.join('_')}_to_users" unless @model.attributes.empty?
106
+
107
+ # include type in db:seed
108
+ append_file 'db/seeds/site.rb' do
109
+ "\n\nPermission.create( :name => '#{@model.singular_name}' ) if Permission.find_by_name('#{@model.singular_name}').nil?"
110
+ end
111
+ # run rake db:seeds
112
+ if yes?('Run rake db:seed to create permission type?')
113
+ rake 'db:migrate'
114
+ rake 'db:seed'
115
+ end
116
+ end
117
+
118
+
119
+ def run_rake_db_migrate
120
+ if !options.skip_rake_migrate and !options.skip_migrations and !options.only_interface
121
+ rake('db:migrate') if !options.skip_questions and yes? 'Run rake db:migrate?'
122
+ end
123
+ end
124
+
125
+ private
126
+
127
+ # Sets Rails migration timestamp
128
+ def self.next_migration_number(dirname) #:nodoc:
129
+ if ActiveRecord::Base.timestamped_migrations
130
+ Time.now.utc.strftime("%Y%m%d%H%M%S")
131
+ else
132
+ "%.3d" % (current_migration_number(dirname) + 1)
133
+ end
134
+ end
135
+
136
+ end
137
+
138
+ end
139
+ end