Class: CafeCar::SessionsGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
Generators
Defined in:
lib/generators/cafe_car/sessions/sessions_generator.rb

Instance Method Summary collapse

Instance Method Details

#create_sessionsObject



6
7
8
# File 'lib/generators/cafe_car/sessions/sessions_generator.rb', line 6

def create_sessions
  migration "create_sessions"
end

#show_readmeObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/generators/cafe_car/sessions/sessions_generator.rb', line 10

def show_readme
  return unless behavior == :invoke

  say <<~MSG

    CafeCar sessions are enabled. The Session model and SessionPolicy ship
    with the engine, so all this added is the `sessions` table.

    Next:
      - Run `bin/rails db:migrate`.
      - Make sure your user model has `has_secure_password` and an `email`.
      - Mounting the engine exposes /session (login). To expose it without
        mounting, add to config/routes.rb:
          resource :session, only: %i[new create destroy],
                   controller: "cafe_car/sessions"
      - If your user model isn't `User`, set CafeCar.user_class_name in an
        initializer (e.g. `CafeCar.user_class_name = "Account"`).
  MSG
end