Monday, February 21, 2011

Using Rake on a gem with dependencies

I have a gem that requires a 'Cms' namespace to be present when running.

However, when running rake tasks, nothing works as this Cms namespace isn't present. How do I get my rake tasks to work?

From stackoverflow
  • You can either, load your project source into the Rakefile (like Rails would do) or define a dummy module with the name Cms on your project.

    # Rakefile
    module Cms; end
    
    task :my_task do
      # ..
    end
    

    If you are on rails, and this gem is a dependency, you just have to make your task dependent of the :environment rails' task.

    # some_task.rake
    task :my_task => :environment do
      # ..
    end
    

    Hope this helps.

0 comments:

Post a Comment