Skip to content

Commit

Permalink
Added the Rails 3 generator
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Engel committed Nov 8, 2010
1 parent f39eb22 commit 421eaa0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 20 deletions.
22 changes: 22 additions & 0 deletions lib/generators/enrichments/enrichments_generator.rb
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,22 @@
class EnrichmentsGenerator < Rails::Generators::Base

desc "Creates entities used by Enrichments (e9s)"
class_option :user_model , :type => :string , :default => "User" , :aliases => "-u" , :desc => "The name of the Authlogic user model."
class_option :content_model , :type => :string , :default => "CmsContent" , :aliases => "-c" , :desc => "The name of the CMS content model."
class_option :translation_model, :type => :string , :default => "Translation", :aliases => "-t" , :desc => "The name of the I18n translation model."
class_option :migrate , :type => :boolean, :default => false , :aliases => "-m" , :desc => "Run 'rake db:migrate' after generating model and migration"

def generate_rich_cms_files
generate "rich:authlogic_user", options[:user_model]
generate "rich:cms_content", options[:content_model]
end

def generate_rich_i18n_files
generate "rich:translation", options[:translation_model]
end

def migrate
rake "db:migrate" if options[:migrate]
end

end
20 changes: 0 additions & 20 deletions rails_generators/enrichments/enrichments_generator.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -20,26 +20,6 @@ def after_generate
system "rake db:migrate" if options[:migrate] system "rake db:migrate" if options[:migrate]
end end


def model_file_name
@name.underscore
end

def model_class_name
@name.classify
end

def table_name
model_file_name.gsub("/", "_").pluralize
end

def migration_file_name
"create_#{table_name}"
end

def migration_class_name
migration_file_name.camelize
end

protected protected


def add_options!(opt) def add_options!(opt)
Expand Down

0 comments on commit 421eaa0

Please sign in to comment.