Created
November 9, 2010 22:49
-
-
Save cmaujean/669992 to your computer and use it in GitHub Desktop.
running a generator programatically
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Must be run in the context of your rails app | |
# if you put this in a rake task, you'll need to ensure the task depends on the :environment task | |
require 'rails/generators' | |
require "#{::Rails.root.to_s}/lib/generators/foo_bar/article/article_generator.rb" | |
# make a generator (new calls .shift on the first arg, so it must be looking for an array) | |
gen = FooBar::ArticleGenerator.new(["Der title of der article"]) | |
# run your create_ methods here: | |
gen.create_article | |
gen.create_article_file |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment