Skip to content

Commit 449bd7f

Browse files
committed
Annotation position defaulted to 'before'. Bugfix: annotate_models.rake uses string instead of symbol.
1 parent 0325656 commit 449bd7f

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

lib/annotate/annotate_models.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,9 @@ def annotate_one_file(file_name, info_block, options={})
145145
# But, if there *was* no old schema info, we simply need to insert it
146146
if new_content == old_content
147147
old_content.sub!(encoding, '')
148-
new_content = options[:position] == 'before' ?
149-
(encoding_header + info_block + old_content) :
150-
(encoding_header + (old_content =~ /\n$/ ? old_content : old_content + '\n') + info_block)
148+
new_content = options[:position] == 'after' ?
149+
(encoding_header + (old_content =~ /\n$/ ? old_content : old_content + '\n') + info_block) :
150+
(encoding_header + info_block + old_content)
151151
end
152152

153153
File.open(file_name, "wb") { |f| f.puts new_content }

lib/tasks/annotate_models.rake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ task :annotate_models => :environment do
55
true_re = /(true|t|yes|y|1)$/i
66

77
options={}
8-
options[:position_in_class] = ENV['position_in_class'] || ENV['position'] || :before
9-
options[:position_in_fixture] = ENV['position_in_fixture'] || ENV['position'] || :before
8+
options[:position_in_class] = ENV['position_in_class'] || ENV['position'] || 'before'
9+
options[:position_in_fixture] = ENV['position_in_fixture'] || ENV['position'] || 'before'
1010
options[:show_indexes] = ENV['show_indexes'] =~ true_re
1111
options[:simple_indexes] = ENV['simple_indexes'] =~ true_re
1212
options[:model_dir] = ENV['model_dir']

0 commit comments

Comments
 (0)