Class: ApprovalEngine::Generators::ViewsGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/approval_engine/views/views_generator.rb

Overview

Copies an example approvals controller and views into the host app. They are intentionally unstyled and minimal — you own them, theme them, rename them. The engine ships the mechanism; the customer-facing UI is yours.

rails generate approval_engine:views

Instance Method Summary collapse

Instance Method Details

#copy_controllerObject



15
16
17
# File 'lib/generators/approval_engine/views/views_generator.rb', line 15

def copy_controller
  copy_file "approvals_controller.rb", "app/controllers/approvals_controller.rb"
end

#copy_viewsObject



19
20
21
# File 'lib/generators/approval_engine/views/views_generator.rb', line 19

def copy_views
  directory "approvals", "app/views/approvals"
end

#routes_hintObject



23
24
25
26
27
28
29
30
# File 'lib/generators/approval_engine/views/views_generator.rb', line 23

def routes_hint
  say "\nAdd routes for the copied controller, for example:", :green
  say <<~RUBY
    resources :approvals, only: :index do
      member { patch :approve; patch :reject }
    end
  RUBY
end