Skip to content

Latest commit

 

History

History

rake

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 

Rake

  • Avoid defining methods inside of Rake namespaces. This will define methods at the top level and interfere with things like factories. link

  • Except in one offs, avoid defining new logic in rake tasks, use a class instead. link

    Example
    ## Bad
    namespace :users do
      desc "Decrements all users rank"
      task decrement_rank: :environment do
        User.where("rank > 0").update_all("rank = rank - 1")
      end
    end
    
    ## Good
    namespace :users do
      desc "Decrements all users rank"
      task decrement_rank: :environment do
        User.decrement_all_ranks
      end
    end