aboutsummaryrefslogtreecommitdiffstats
path: root/generators/refinery_blog/refinery_blog_generator.rb
diff options
context:
space:
mode:
Diffstat (limited to 'generators/refinery_blog/refinery_blog_generator.rb')
-rw-r--r--generators/refinery_blog/refinery_blog_generator.rb41
1 files changed, 24 insertions, 17 deletions
diff --git a/generators/refinery_blog/refinery_blog_generator.rb b/generators/refinery_blog/refinery_blog_generator.rb
index 0739498..d18268b 100644
--- a/generators/refinery_blog/refinery_blog_generator.rb
+++ b/generators/refinery_blog/refinery_blog_generator.rb
@@ -7,37 +7,44 @@ class RefineryBlogGenerator < Rails::Generator::NamedBase
end
def banner
- "Usage: script/generate refinery_blog"
+ 'Usage: script/generate refinery_blog'
end
def manifest
- tables = %w(posts comments categories).map{|t| "blog_#{t}"}
record do |m|
m.template('seed.rb', 'db/seeds/refinerycms_blog.rb')
m.migration_template('migration.rb', 'db/migrate',
- :migration_file_name => "create_blog_structure",
+ :migration_file_name => 'create_blog_structure',
:assigns => {
- :migration_name => "CreateBlogStructure",
+ :migration_name => 'CreateBlogStructure',
:tables => [{
- :table_name => tables.first,
+ :table_name => 'blog_posts',
:attributes => [
- Rails::Generator::GeneratedAttribute.new("title", "string"),
- Rails::Generator::GeneratedAttribute.new("body", "text"),
- Rails::Generator::GeneratedAttribute.new("draft", "boolean")
- ]
+ Rails::Generator::GeneratedAttribute.new('title', 'string'),
+ Rails::Generator::GeneratedAttribute.new('body', 'text'),
+ Rails::Generator::GeneratedAttribute.new('draft', 'boolean')
+ ], :id => true
},{
- :table_name => tables.second,
+ :table_name => 'blog_comments',
:attributes => [
- Rails::Generator::GeneratedAttribute.new("name", "string"),
- Rails::Generator::GeneratedAttribute.new("email", "string"),
- Rails::Generator::GeneratedAttribute.new("body", "text")
- ]
+ Rails::Generator::GeneratedAttribute.new('name', 'string'),
+ Rails::Generator::GeneratedAttribute.new('email', 'string'),
+ Rails::Generator::GeneratedAttribute.new('body', 'text'),
+ Rails::Generator::GeneratedAttribute.new('approved', 'boolean'),
+ Rails::Generator::GeneratedAttribute.new('blog_post_id', 'integer')
+ ], :id => true
},{
- :table_name => tables.third,
+ :table_name => 'blog_categories',
:attributes => [
- Rails::Generator::GeneratedAttribute.new("title", "string")
- ]
+ Rails::Generator::GeneratedAttribute.new('title', 'string')
+ ], :id => true
+ },{
+ :table_name => 'blog_categories_blog_posts',
+ :attributes => [
+ Rails::Generator::GeneratedAttribute.new('blog_category_id', 'integer'),
+ Rails::Generator::GeneratedAttribute.new('blog_post_id', 'integer')
+ ], :id => false
}]
})
end