Commit 449bd7f1 by David Xia

Annotation position defaulted to 'before'. Bugfix: annotate_models.rake uses…

Annotation position defaulted to 'before'. Bugfix: annotate_models.rake uses string instead of symbol.
parent 03256565
......@@ -145,9 +145,9 @@ module AnnotateModels
# But, if there *was* no old schema info, we simply need to insert it
if new_content == old_content
old_content.sub!(encoding, '')
new_content = options[:position] == 'before' ?
(encoding_header + info_block + old_content) :
(encoding_header + (old_content =~ /\n$/ ? old_content : old_content + '\n') + info_block)
new_content = options[:position] == 'after' ?
(encoding_header + (old_content =~ /\n$/ ? old_content : old_content + '\n') + info_block) :
(encoding_header + info_block + old_content)
end
File.open(file_name, "wb") { |f| f.puts new_content }
......
......@@ -5,8 +5,8 @@ task :annotate_models => :environment do
true_re = /(true|t|yes|y|1)$/i
options={}
options[:position_in_class] = ENV['position_in_class'] || ENV['position'] || :before
options[:position_in_fixture] = ENV['position_in_fixture'] || ENV['position'] || :before
options[:position_in_class] = ENV['position_in_class'] || ENV['position'] || 'before'
options[:position_in_fixture] = ENV['position_in_fixture'] || ENV['position'] || 'before'
options[:show_indexes] = ENV['show_indexes'] =~ true_re
options[:simple_indexes] = ENV['simple_indexes'] =~ true_re
options[:model_dir] = ENV['model_dir']
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment