开发者

can i pass parameter with annotate_model rake task in rails

开发者 https://www.devze.com 2023-01-13 16:24 出处:网络
I want to annotate a specific model not all. Can i pass a model name or table name with annotate_model 开发者_开发技巧rake task to annotate specific model ?Modify vendor/plugins/annotate_models/lib/a

I want to annotate a specific model not all.

Can i pass a model name or table name with annotate_model 开发者_开发技巧rake task to annotate specific model ?


Modify vendor/plugins/annotate_models/lib/annotate_models.rb

replace

def self.do_annotations

with

def self.do_annotations(model_names=nil)

replace

model_names = model_names.split(',') unless model_names.nil?
model_names = model_names.nil? ? self.get_model_names : model_names  
model_names.each do |m|

with

self.get_model_names.each do |m|

Modify libs/annotate_models_tasks.rake

replace

AnnotateModels.do_annotations

with

AnnotateModels.do_annotations ENV['MODEL_NAMES']

Now you can pass parameter to the rake task..

Example:

 rake annotate_models MODEL_NAMES=csv_header,csv_columne    

pass filenames without .rb in parameter.

May be that will help ...

0

精彩评论

暂无评论...
验证码 换一张
取 消