Class: Toggly::Generators::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/toggly/rails/generators/toggly/install/install_generator.rb

Overview

Generator for Toggly Rails initializer.

Examples:

rails generate toggly:install

Instance Method Summary collapse

Instance Method Details

#create_initializer_fileObject



19
20
21
# File 'lib/toggly/rails/generators/toggly/install/install_generator.rb', line 19

def create_initializer_file
  template "toggly.rb.erb", "config/initializers/toggly.rb"
end

#show_post_install_messageObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/toggly/rails/generators/toggly/install/install_generator.rb', line 23

def show_post_install_message
  say ""
  say "Toggly has been installed! 🎉", :green
  say ""
  say "Next steps:"
  say "  1. Update config/initializers/toggly.rb with your app key"
  say "  2. Or add to your credentials: rails credentials:edit"
  say "     toggly:"
  say "       app_key: your-app-key"
  say "       environment: Production"
  say ""
  say "Usage in controllers:"
  say "  if feature_enabled?(:my_feature)"
  say "    # feature is on"
  say "  end"
  say ""
  say "Usage in views:"
  say "  <% if feature_enabled?(:my_feature) %>"
  say "    Feature content"
  say "  <% end %>"
  say ""
end