merit 3.0.0 → 4.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +5 -5
  2. data/Gemfile +3 -20
  3. data/NEWS.md +30 -0
  4. data/README.md +14 -2
  5. data/RELEASING.md +16 -0
  6. data/Rakefile +13 -1
  7. data/app/models/merit/badge.rb +2 -19
  8. data/lib/merit.rb +13 -35
  9. data/lib/merit/{rules_badge_methods.rb → badge_rules_methods.rb} +0 -0
  10. data/lib/merit/base_target_finder.rb +1 -6
  11. data/lib/merit/{model_additions.rb → class_methods.rb} +2 -19
  12. data/lib/merit/controller_extensions.rb +4 -22
  13. data/lib/{generators → merit/generators}/active_record/install_generator.rb +12 -8
  14. data/lib/{generators → merit/generators}/active_record/merit_generator.rb +8 -4
  15. data/lib/{generators → merit/generators}/active_record/remove_generator.rb +9 -5
  16. data/lib/{generators/active_record/templates/add_merit_fields_to_model.rb → merit/generators/active_record/templates/add_merit_fields_to_model.erb} +1 -1
  17. data/lib/{generators/active_record/templates/create_badges_sashes.rb → merit/generators/active_record/templates/create_badges_sashes.erb} +1 -1
  18. data/lib/{generators/active_record/templates/create_merit_actions.rb → merit/generators/active_record/templates/create_merit_actions.erb} +1 -1
  19. data/lib/{generators/active_record/templates/create_merit_activity_logs.rb → merit/generators/active_record/templates/create_merit_activity_logs.erb} +1 -1
  20. data/lib/{generators/active_record/templates/create_sashes.rb → merit/generators/active_record/templates/create_sashes.erb} +1 -1
  21. data/lib/{generators/active_record/templates/create_scores_and_points.rb → merit/generators/active_record/templates/create_scores_and_points.erb} +2 -2
  22. data/lib/{generators/active_record/templates/remove_merit_fields_from_model.rb → merit/generators/active_record/templates/remove_merit_fields_from_model.erb} +1 -1
  23. data/lib/{generators/active_record/templates/remove_merit_tables.rb → merit/generators/active_record/templates/remove_merit_tables.erb} +1 -1
  24. data/lib/merit/generators/install_generator.rb +21 -0
  25. data/lib/{generators/merit → merit/generators}/merit_generator.rb +7 -2
  26. data/lib/{generators/merit → merit/generators}/remove_generator.rb +7 -2
  27. data/lib/{generators/merit/templates/merit.rb → merit/generators/templates/merit.erb} +1 -4
  28. data/lib/{generators/merit/templates/merit_badge_rules.rb → merit/generators/templates/merit_badge_rules.erb} +0 -0
  29. data/lib/{generators/merit/templates/merit_point_rules.rb → merit/generators/templates/merit_point_rules.erb} +0 -0
  30. data/lib/{generators/merit/templates/merit_rank_rules.rb → merit/generators/templates/merit_rank_rules.erb} +0 -0
  31. data/{app/models/merit/action.rb → lib/merit/models/action_concern.rb} +12 -10
  32. data/lib/merit/models/active_record/action.rb +11 -0
  33. data/lib/merit/models/active_record/{merit/activity_log.rb → activity_log.rb} +4 -6
  34. data/lib/merit/models/active_record/{merit/badges_sash.rb → badges_sash.rb} +4 -4
  35. data/lib/merit/models/active_record/{merit/sash.rb → sash.rb} +5 -2
  36. data/lib/merit/models/active_record/{merit/score.rb → score.rb} +4 -1
  37. data/lib/merit/models/badges_sash_concern.rb +13 -0
  38. data/lib/merit/models/base/badges_sash.rb +1 -1
  39. data/lib/merit/models/base/sash.rb +1 -1
  40. data/lib/merit/models/sash_concern.rb +53 -0
  41. data/lib/merit/{rules_points_methods.rb → point_rules_methods.rb} +0 -0
  42. data/lib/merit/{rules_rank_methods.rb → rank_rules_methods.rb} +3 -18
  43. data/merit.gemspec +7 -5
  44. data/test/dummy/app/controllers/comments_controller.rb +1 -1
  45. data/test/dummy/app/controllers/registrations_controller.rb +1 -1
  46. data/test/dummy/app/models/address.rb +1 -12
  47. data/test/dummy/app/models/comment.rb +3 -25
  48. data/test/dummy/app/models/user.rb +1 -18
  49. data/test/dummy/config/application.rb +8 -10
  50. data/test/dummy/config/application_api_only.rb +28 -0
  51. data/test/dummy/config/environment_api_only.rb +7 -0
  52. data/test/dummy/config/initializers/new_framework_defaults.rb +3 -0
  53. data/test/dummy/db/schema.rb +55 -59
  54. data/test/integration/navigation_test.rb +2 -2
  55. data/test/test_helper.rb +11 -12
  56. data/test/unit/base_target_finder_test.rb +7 -26
  57. data/test/unit/merit_unit_test.rb +13 -17
  58. data/test/unit/rule_unit_test.rb +15 -8
  59. data/test/unit/rules_matcher_test.rb +9 -6
  60. data/test/unit/sash_finder_test.rb +5 -5
  61. data/test/unit/score_test.rb +1 -1
  62. data/test/unit/target_finder_test.rb +13 -13
  63. metadata +64 -73
  64. data/UPGRADING.md +0 -256
  65. data/lib/generators/active_record/templates/add_target_data_to_merit_actions.rb +0 -5
  66. data/lib/generators/active_record/upgrade_generator.rb +0 -36
  67. data/lib/generators/merit/install_generator.rb +0 -16
  68. data/lib/generators/merit/upgrade_generator.rb +0 -7
  69. data/lib/merit/models/active_record/merit/action.rb +0 -12
  70. data/lib/merit/models/mongoid/merit/action.rb +0 -18
  71. data/lib/merit/models/mongoid/merit/activity_log.rb +0 -11
  72. data/lib/merit/models/mongoid/merit/badges_sash.rb +0 -22
  73. data/lib/merit/models/mongoid/merit/sash.rb +0 -30
  74. data/lib/merit/models/mongoid/merit/score.rb +0 -45
  75. data/test/dummy/db/migrate/20140906225844_create_players.rb +0 -8
  76. data/test/dummy/public/javascripts/application.js +0 -2
  77. data/test/dummy/public/javascripts/controls.js +0 -965
  78. data/test/dummy/public/javascripts/dragdrop.js +0 -974
  79. data/test/dummy/public/javascripts/effects.js +0 -1123
  80. data/test/dummy/public/javascripts/prototype.js +0 -6001
  81. data/test/dummy/public/javascripts/rails.js +0 -191
  82. data/test/orm/active_record.rb +0 -2
  83. data/test/orm/mongoid.rb +0 -6
  84. data/test/orm_models/active_record.rb +0 -11
  85. data/test/orm_models/mongoid.rb +0 -15
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 1c2cb7b1562ee27518561243969673e6bc9796f4
4
- data.tar.gz: ac96051e01a3ad6223ebc0a84ffa7d0f7845dc67
2
+ SHA256:
3
+ metadata.gz: 81342bb2e6b393dca1eed04fb9918e964d7add7e4a5144da975deb98fa05651e
4
+ data.tar.gz: 6b942ef093394de05ad17ddc74b2c802ed3e4e648f4452b1497b0e1a3521eefb
5
5
  SHA512:
6
- metadata.gz: 74b144eb96c51f83aacb529ac9d87962e9fed9e48f6af0da365b00df773597c28f79a66f8ab3048df3c9042a62e46371442661123b4321f0a9d333fa8f97ed67
7
- data.tar.gz: 1022b3357c719d183dfa1b2b068943fecefa009263aeed1905d051310c29e644333c087cadbd5eec433d0542a11abf5174121c38f003d6b657e937895345ca44
6
+ metadata.gz: 9054350196c3dbb3d9a4542519a100f1ee1f34bc8bd2374de067fea912910afb1d795c78bd120e9b5007c2032dd0aecb4d113e21d7470232f00be15c2fe41c88
7
+ data.tar.gz: e86554c92ac022a624a911a2e5cdb81562cde41babc2c2fa195aa78e4c264ef389db106c5907ba05f7db6bb4f4ce9a276d57d49b34d78138eee6c633dbed655c
data/Gemfile CHANGED
@@ -2,27 +2,10 @@ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
4
 
5
- version = ENV['RAILS_VERSION'] || '5.0.3'
6
- gem 'rails', version
7
-
8
- case ENV['ORM']
9
- when 'active_record'
10
- gem 'activerecord'
11
- when 'mongoid'
12
- gem 'mongoid'
13
- end
5
+ gem 'rails', "~> #{ENV.fetch('RAILS_VERSION', 6.0)}"
14
6
 
15
7
  group :development, :test do
16
- gem 'activerecord-jdbcsqlite3-adapter', :platforms => [:jruby]
17
- gem 'sqlite3', '~> 1.3.8', :platforms => [:ruby, :mswin, :mingw]
18
- end
19
-
20
- platforms :rbx do
21
- gem 'rubysl', '~> 2.0'
22
- gem 'psych'
23
- gem 'racc'
24
- gem 'minitest', '~> 5.10', '!= 5.10.2'
25
- gem 'rubinius-developer_tools'
8
+ gem 'sqlite3', '~> 1.4'
26
9
  end
27
10
 
28
- gem 'coveralls', require: false
11
+ gem 'coveralls', '~> 0.8.23', require: false
data/NEWS.md CHANGED
@@ -2,6 +2,36 @@
2
2
 
3
3
  User-visible changes worth mentioning.
4
4
 
5
+ ## 4.0.1
6
+
7
+ - [#351] Fix bug on generating migrations
8
+
9
+ ## 4.0.0
10
+
11
+ - Stop testing on Rails 5.1
12
+ - Drop support for mongoid
13
+ - Drop v2 upgrade generators
14
+ - Enable Zeitwerk gem mode (and renames internal merit constants)
15
+
16
+ ## 3.0.3
17
+
18
+ - Test against Ruby 2.6 and Rails 6
19
+ - Use `find_each` in favor of `map` in `Merit::Action.check_unprocessed`
20
+ - Allow finding badges defined with symbol names
21
+ - Remove `Badge#last_granted` method (deprecated in merit <2.0)
22
+
23
+ ## 3.0.2
24
+
25
+ - [#287] Make Sash an optional dependency, fixing issues in Rails 5.1.
26
+ - [#297] Initialize merit once both for API or non-API apps
27
+ - Updates dependencies
28
+
29
+ ## 3.0.1
30
+
31
+ - [#282] Run action controller load hook only once
32
+ - [#284] Add migration version to active record migrations
33
+ - Add RELEASING.md document
34
+
5
35
  ## 3.0.0
6
36
 
7
37
  - [#276] Drops Rails <5 version support. Drops deprecated `action_filter` call.
data/README.md CHANGED
@@ -38,8 +38,7 @@ and Rankings.
38
38
  2. Run `rails g merit:install`. This creates several migrations.
39
39
  3. Run `rails g merit MODEL_NAME` (e.g. `user`). This creates a migration and adds `has_merit` to MODEL_NAME.
40
40
  4. Run `rake db:migrate`
41
- 5. Define badges in `config/initializers/merit.rb`. You can also define ORM:
42
- `:active_record` (default) or `:mongoid`.
41
+ 5. Define badges in `config/initializers/merit.rb`
43
42
  6. Configure reputation rules for your application in `app/models/merit/*`
44
43
 
45
44
 
@@ -114,6 +113,19 @@ grant_on ['users#create', 'users#update'], badge: 'autobiographer', temporary: t
114
113
  end
115
114
  ```
116
115
 
116
+ If your controller is under a namespace other than root (example:
117
+ `Api::ModelController`) then for merit to find your object automatically you
118
+ must specify the model class and not forget that your action is of the form
119
+ `namespace/models#action`.
120
+
121
+ See an example of a `Post` model that belongs to user:
122
+
123
+ ```ruby
124
+ grant_on 'api/posts#create', badge: 'first-post', model_name: 'Post', to: :user do |post|
125
+ post.user.posts.count >= 1
126
+ end
127
+ ```
128
+
117
129
  ## Other Actions
118
130
 
119
131
  ```ruby
@@ -0,0 +1,16 @@
1
+ # Releasing
2
+
3
+ 1. Update `NEWS.md` to reflect the changes since last release.
4
+ 1. Tag the release: `git tag vVERSION -a -s`. The tag message should contain the
5
+ appropriate `NEWS.md` subsection.
6
+ 1. Push changes: `git push --tags`
7
+ 1. Build and publish to rubygems:
8
+ ```bash
9
+ gem build merit.gemspec
10
+ gem push merit-*.gem
11
+ ```
12
+
13
+ 1. Add a new GitHub release:
14
+ https://github.com/merit-gem/merit/releases/new?tag=vVERSION
15
+ 1. Announce the new release, making sure to say "thank you" to the contributors
16
+ who helped shape this version!
data/Rakefile CHANGED
@@ -8,7 +8,11 @@ end
8
8
  require 'rake/testtask'
9
9
 
10
10
  desc 'Default: run tests for all ORMs.'
11
- task default: :test
11
+ task default: [:setup, :test, :api_test]
12
+
13
+ task :setup do
14
+ system "cd test/dummy && rake db:migrate && rake db:test:prepare"
15
+ end
12
16
 
13
17
  Rake::TestTask.new(:test) do |t|
14
18
  t.libs << 'lib'
@@ -17,6 +21,14 @@ Rake::TestTask.new(:test) do |t|
17
21
  t.verbose = true
18
22
  end
19
23
 
24
+ Rake::TestTask.new(:api_test) do |t|
25
+ t.libs << 'lib'
26
+ t.libs << 'test'
27
+ t.test_files = FileList['test/**/*_test.rb'].exclude(/navigation_test.rb/)
28
+ t.verbose = true
29
+ t.options = '-- -api-only'
30
+ end
31
+
20
32
  begin
21
33
  require 'rdoc/task'
22
34
  Rake::RDocTask.new(:rdoc) do |rdoc|
@@ -18,7 +18,7 @@ module Merit
18
18
  end
19
19
 
20
20
  def by_name(name)
21
- find { |b| b.name == name.to_s }
21
+ find { |b| b.name.to_s == name.to_s }
22
22
  end
23
23
 
24
24
  def by_level(level)
@@ -26,14 +26,6 @@ module Merit
26
26
  end
27
27
  end
28
28
 
29
- def _mongoid_sash_in(sashes)
30
- {:sash_id.in => sashes}
31
- end
32
-
33
- def _active_record_sash_in(sashes)
34
- {sash_id: sashes}
35
- end
36
-
37
29
  class << self
38
30
  def find_by_name_and_level(name, level)
39
31
  badges = Merit::Badge.by_name(name)
@@ -45,22 +37,13 @@ module Merit
45
37
  badge
46
38
  end
47
39
 
48
- # DEPRECATED: `last_granted` will be removed from merit, please refer to:
49
- # https://github.com/tute/merit/wiki/How-to-show-last-granted-badges
50
- def last_granted(options = {})
51
- warn '[merit] [DEPRECATION] `last_granted` will be removed from merit, please refer to: https://github.com/tute/merit/wiki/How-to-show-last-granted-badges'
52
- options[:since_date] ||= 1.month.ago
53
- options[:limit] ||= 10
54
- BadgesSash.last_granted(options)
55
- end
56
-
57
40
  # Defines Badge#meritable_models method, to get related
58
41
  # entries with certain badge. For instance, Badge.find(3).users
59
42
  # orm-specified
60
43
  def _define_related_entries_method(meritable_class_name)
61
44
  define_method(:"#{meritable_class_name.underscore.pluralize}") do
62
45
  sashes = BadgesSash.where(badge_id: id).pluck(:sash_id)
63
- meritable_class_name.constantize.where(send "_#{Merit.orm}_sash_in", sashes)
46
+ meritable_class_name.constantize.where(sash_id: sashes)
64
47
  end
65
48
  end
66
49
  end
@@ -1,17 +1,4 @@
1
- require 'merit/rule'
2
- require 'merit/rules_badge_methods'
3
- require 'merit/rules_points_methods'
4
- require 'merit/rules_rank_methods'
5
- require 'merit/rules_matcher'
6
- require 'merit/controller_extensions'
7
- require 'merit/model_additions'
8
- require 'merit/judge'
9
- require 'merit/reputation_change_observer'
10
- require 'merit/sash_finder'
11
- require 'merit/base_target_finder'
12
- require 'merit/target_finder'
13
- require 'merit/models/base/sash'
14
- require 'merit/models/base/badges_sash'
1
+ require 'zeitwerk'
15
2
 
16
3
  module Merit
17
4
  def self.setup
@@ -24,7 +11,6 @@ module Merit
24
11
  @config.checks_on_each_request
25
12
  end
26
13
 
27
- # # Define ORM
28
14
  def self.orm
29
15
  @config.orm || :active_record
30
16
  end
@@ -49,11 +35,6 @@ module Merit
49
35
  @config.add_observer(class_name)
50
36
  end
51
37
 
52
- def self.upgrade_target_data_warning
53
- Rails.logger.warn '[merit] Missing column: target_data. Run `rails ' \
54
- 'generate merit:upgrade` and `rake db:migrate` to add it.'
55
- end
56
-
57
38
  class Configuration
58
39
  attr_accessor :checks_on_each_request, :orm, :user_model_name, :observers,
59
40
  :current_user_method
@@ -81,8 +62,7 @@ module Merit
81
62
 
82
63
  initializer 'merit.controller' do |app|
83
64
  extend_orm_with_has_merit
84
- require_models
85
- ActiveSupport.on_load(:action_controller) do
65
+ ActiveSupport.on_load(action_controller_hook) do
86
66
  begin
87
67
  # Load app rules on boot up
88
68
  Merit::AppBadgeRules = Merit::BadgeRules.new.defined_rules
@@ -96,22 +76,20 @@ module Merit
96
76
  end
97
77
  end
98
78
 
99
- def require_models
100
- require 'merit/models/base/sash'
101
- require 'merit/models/base/badges_sash'
102
- require "merit/models/#{Merit.orm}/merit/activity_log"
103
- require "merit/models/#{Merit.orm}/merit/badges_sash"
104
- require "merit/models/#{Merit.orm}/merit/sash"
105
- require "merit/models/#{Merit.orm}/merit/score"
79
+ def extend_orm_with_has_merit
80
+ ActiveRecord::Base.include(Merit)
106
81
  end
107
82
 
108
- def extend_orm_with_has_merit
109
- if Object.const_defined?('ActiveRecord')
110
- ActiveRecord::Base.send :include, Merit
111
- end
112
- if Object.const_defined?('Mongoid')
113
- Mongoid::Document.send :include, Merit
83
+ def action_controller_hook
84
+ if Rails.application.config.api_only
85
+ :action_controller_api
86
+ else
87
+ :action_controller_base
114
88
  end
115
89
  end
116
90
  end
117
91
  end
92
+
93
+ loader = Zeitwerk::Loader.for_gem
94
+ loader.setup
95
+ loader.eager_load
@@ -25,12 +25,7 @@ module Merit
25
25
  end
26
26
 
27
27
  def reanimate_target_from_action
28
- if @action.respond_to? :target_data
29
- YAML.load(@action.target_data)
30
- else
31
- Merit.upgrade_target_data_warning
32
- nil
33
- end
28
+ YAML.load(@action.target_data)
34
29
  end
35
30
  end
36
31
  end
@@ -7,10 +7,8 @@ module Merit
7
7
  # That's why MeritableModel belongs_to Sash. Can't use
8
8
  # dependent: destroy as it may raise FK constraint exceptions. See:
9
9
  # https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/1079-belongs_to-dependent-destroy-should-destroy-self-before-assocation
10
- belongs_to :sash, class_name: 'Merit::Sash', inverse_of: nil
11
- attr_accessible :sash if show_attr_accessible?
10
+ belongs_to :sash, class_name: 'Merit::Sash', inverse_of: nil, optional: true
12
11
 
13
- send :"_merit_#{Merit.orm}_specific_config"
14
12
  _merit_delegate_methods_to_sash
15
13
  _merit_define_badge_related_entries_method
16
14
  _merit_sash_initializer
@@ -23,26 +21,11 @@ module Merit
23
21
  methods.each { |method| delegate method, to: :_sash }
24
22
  end
25
23
 
26
- def _merit_active_record_specific_config
27
- end
28
-
29
- def _merit_mongoid_specific_config
30
- field :level, type: Integer, default: 0
31
- def find_by_id(id)
32
- where(_id: id).first
33
- end
34
- end
35
-
36
24
  def _merit_define_badge_related_entries_method
37
25
  meritable_class_name = name.demodulize
38
26
  Merit::Badge._define_related_entries_method(meritable_class_name)
39
27
  end
40
28
 
41
- def show_attr_accessible?
42
- defined?(ProtectedAttributes) ||
43
- !defined?(ActionController::StrongParameters)
44
- end
45
-
46
29
  # _sash initializes a sash if doesn't have one yet.
47
30
  # From Rails 3.2 we can override association methods to do so
48
31
  # transparently, but merit supports Rails ~> 3.0.0. See:
@@ -50,7 +33,7 @@ module Merit
50
33
  def _merit_sash_initializer
51
34
  define_method(:_sash) do
52
35
  # TODO: reload.sash is not regression tested
53
- sash || reload.sash || update_attributes(sash: Sash.create)
36
+ sash || reload.sash || update(sash: Sash.create)
54
37
  sash
55
38
  end
56
39
  end
@@ -27,16 +27,8 @@ module Merit
27
27
  had_errors: had_errors?,
28
28
  target_model: controller_path,
29
29
  target_id: target_id,
30
- }.merge(target_data_hash)
31
- end
32
-
33
- def target_data_hash
34
- if Merit::Action.new.respond_to?(:target_data)
35
- { target_data: target_object.to_yaml }
36
- else
37
- Merit.upgrade_target_data_warning
38
- {}
39
- end
30
+ target_data: target_object.to_yaml,
31
+ }
40
32
  end
41
33
 
42
34
  def rules_defined?
@@ -69,21 +61,11 @@ module Merit
69
61
 
70
62
  def target_id
71
63
  target_id = target_object.try(:id)
72
- # If target_id is nil
73
- # then use params[:id].
74
- if target_id.nil? && send("check_#{Merit.orm}_id", params[:id])
64
+ # If target_id is nil use (only digits of) params[:id]
65
+ if target_id.nil? && params[:id].to_s =~ /^[0-9]+$/
75
66
  target_id = params[:id]
76
67
  end
77
68
  target_id
78
69
  end
79
-
80
- # This check avoids trying to set a slug as integer FK
81
- def check_active_record_id(id)
82
- id.to_s =~ /^[0-9]+$/
83
- end
84
-
85
- def check_mongoid_id(id)
86
- id.to_s =~ /^[0-9a-fA-F]{24}$/
87
- end
88
70
  end
89
71
  end
@@ -1,8 +1,8 @@
1
1
  require 'rails/generators/active_record'
2
2
 
3
- module ActiveRecord
4
- module Generators
5
- class InstallGenerator < Rails::Generators::Base
3
+ module Merit
4
+ module Generators::ActiveRecord
5
+ class InstallGenerator < ::Rails::Generators::Base
6
6
  include Rails::Generators::Migration
7
7
 
8
8
  source_root File.expand_path('../templates', __FILE__)
@@ -13,21 +13,25 @@ module ActiveRecord
13
13
  end
14
14
 
15
15
  def copy_migrations_and_model
16
- migration_template 'create_merit_actions.rb',
16
+ migration_template 'create_merit_actions.erb',
17
17
  'db/migrate/create_merit_actions.rb'
18
18
 
19
- migration_template 'create_merit_activity_logs.rb',
19
+ migration_template 'create_merit_activity_logs.erb',
20
20
  'db/migrate/create_merit_activity_logs.rb'
21
21
 
22
- migration_template 'create_sashes.rb',
22
+ migration_template 'create_sashes.erb',
23
23
  'db/migrate/create_sashes.rb'
24
24
 
25
- migration_template 'create_badges_sashes.rb',
25
+ migration_template 'create_badges_sashes.erb',
26
26
  'db/migrate/create_badges_sashes.rb'
27
27
 
28
- migration_template 'create_scores_and_points.rb',
28
+ migration_template 'create_scores_and_points.erb',
29
29
  'db/migrate/create_scores_and_points.rb'
30
30
  end
31
+
32
+ def migration_version
33
+ "[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]"
34
+ end
31
35
  end
32
36
  end
33
37
  end
@@ -1,8 +1,8 @@
1
1
  require 'rails/generators/active_record'
2
2
 
3
- module ActiveRecord
4
- module Generators
5
- class MeritGenerator < ActiveRecord::Generators::Base
3
+ module Merit
4
+ module Generators::ActiveRecord
5
+ class MeritGenerator < ::ActiveRecord::Generators::Base
6
6
  include Rails::Generators::Migration
7
7
 
8
8
  source_root File.expand_path('../templates', __FILE__)
@@ -13,9 +13,13 @@ module ActiveRecord
13
13
  end
14
14
 
15
15
  def copy_migrations_and_model
16
- migration_template 'add_merit_fields_to_model.rb',
16
+ migration_template 'add_merit_fields_to_model.erb',
17
17
  "db/migrate/add_merit_fields_to_#{table_name}.rb"
18
18
  end
19
+
20
+ def migration_version
21
+ "[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]"
22
+ end
19
23
  end
20
24
  end
21
25
  end