Class: Chive::Generators::SeedsGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/chive/seeds_generator.rb

Instance Method Summary collapse

Instance Method Details

#manifestObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/generators/chive/seeds_generator.rb', line 14

def manifest
  append_to_file 'db/seeds.rb' do
    <<-RUBY

# Chive examples
if Rails.env.development?
  user = #{options[:user].camelize}.create(name: 'Example', email: '[email protected]', password: 'password')
  Chive::#{options[:article].camelize}.create(
    title: 'Hello, World!',
    body: %(
<p>This is an example article created by the development seeds (db/seeds.rb).</p>
    ),
    author: user,
    status: 'publish',
    published_at: DateTime.now
  )
end
    RUBY
  end
end