# Best practices to pass in Conditions to Rake task?

**URL:** <https://www.ruby-forum.com/t/best-practices-to-pass-in-conditions-to-rake-task/170687>\
**Category:** Rails\
**Created:** [June 21, 2009, 7:10am UTC](https://www.ruby-forum.com/t/best-practices-to-pass-in-conditions-to-rake-task/170687 "2009-06-21T07:10:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mgiorno](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e274bd/32.png) [@mgiorno](https://www.ruby-forum.com/u/mgiorno)\
**Post date:** [June 21, 2009, 7:10am UTC](https://www.ruby-forum.com/t/best-practices-to-pass-in-conditions-to-rake-task/170687/1 "2009-06-21T07:10:30Z")

</div>

I’m trying to pass in conditions to a find command in a rake task. I’m  
still a little new to this, but what is the best practices for this?  
Should I be passing in a hash or… Any suggestions welcome!

command line: rake mytask conditions=‘condition = 1’

#mytask.rake  
def conditions  
ENV[‘conditions’] || ENV[‘conditions’] || nil  
end

task :metadata =\> :environment do  
klass.find\_each(:start =\> start, :conditions =\> conditions) do  
|record|  
#do stuff  
end  
end

thanks!
