Class: VoteFu::Generators::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
ActiveRecord::Generators::Migration
Defined in:
lib/generators/vote_fu/install/install_generator.rb

Instance Method Summary collapse

Instance Method Details

#create_initializerObject



15
16
17
# File 'lib/generators/vote_fu/install/install_generator.rb', line 15

def create_initializer
  template "initializer.rb", "config/initializers/vote_fu.rb"
end

#create_migrationObject



19
20
21
22
23
24
# File 'lib/generators/vote_fu/install/install_generator.rb', line 19

def create_migration
  migration_template(
    "migration.rb.erb",
    "db/migrate/create_vote_fu_votes.rb"
  )
end

#show_post_install_messageObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/generators/vote_fu/install/install_generator.rb', line 26

def show_post_install_message
  say ""
  say "VoteFu installed successfully!", :green
  say ""
  say "Next steps:"
  say "  1. Run migrations: rails db:migrate"
  say "  2. Add to your models:"
  say ""
  say "     class Post < ApplicationRecord"
  say "       acts_as_voteable"
  say "     end"
  say ""
  say "     class User < ApplicationRecord"
  say "       acts_as_voter"
  say "     end"
  say ""
  say "  3. Start voting:"
  say "     user.upvote(post)"
  say "     user.downvote(post)"
  say "     post.plusminus"
  say ""
end