I'm writing a gem and I want to have an access to the gem rake tasks from my rails app. To do this I use Railties.
I have lib/frontrockets-rails/railtie.rb
with
require 'frontrockets-rails'
require 'rails'
module FrontrocketsRails
class Railtie < Rails::Railtie
railtie_name :frontrockets
rake_tasks do
load 'tasks/frontrockets.rake'
end
end
end
and
lib/frontrockets-rails.rb
with
module FrontrocketsRails
require 'frontrockets-rails/railtie' if defined?(Rails)
end
and of course lib/tasks/frontrockets.rake
namespace :frontrockets do
desc 'Create .bowerrc file'
task :create_bowerrc do
touch '.bowerrc'
end
task :install => [:create_bowerrc] do
end
end
But when I install this gem in my Rails app I still can't execute this rake tasks, there are no them in the rake -T
list.
I've just restarted spring and new rake tasks appeared in my rake -T
list. :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With