Class: Spud::Blog::BlogGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/spud/blog/blog_generator.rb

Instance Method Summary collapse

Instance Method Details

#generateObject



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/generators/spud/blog/blog_generator.rb', line 7

def generate
  @name = blog_name
  @key = blog_name.parameterize.underscore
  @path = ask('What is your blog path?', default: '/' + @name.parameterize)
  @layout = ask('What layout should your blog use?', default: 'application')
  environment(blog_config())
  if ask('Do you want to use custom views?', limited_to: ['y', 'n']) == 'y'
    copy_file 'index.html.erb', Rails.root.join('app/views', @key, 'index.html.erb')
    copy_file 'show.html.erb', Rails.root.join('app/views', @key, 'show.html.erb')
  end
end