Class: EasyTokens::TokensController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/easy_tokens/tokens_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



21
22
23
24
25
26
27
28
29
30
# File 'app/controllers/easy_tokens/tokens_controller.rb', line 21

def create
  @token = Token.new(token_params)
  @token.owner_id = owner_resource.id

  if @token.save
    redirect_to tokens_path, notice: 'Token was successfully created.'
  else
    render :new
  end
end

#deactivate_tokenObject



40
41
42
43
44
45
# File 'app/controllers/easy_tokens/tokens_controller.rb', line 40

def deactivate_token
  @token = Token.find(params[:token_id])
  @token.touch(:deactivated_at)
  @token.save
  redirect_to tokens_path
end

#editObject



18
19
# File 'app/controllers/easy_tokens/tokens_controller.rb', line 18

def edit
end

#indexObject



10
11
12
# File 'app/controllers/easy_tokens/tokens_controller.rb', line 10

def index
  @tokens = Token.all
end

#newObject



14
15
16
# File 'app/controllers/easy_tokens/tokens_controller.rb', line 14

def new
  @token = Token.new
end

#updateObject



32
33
34
35
36
37
38
# File 'app/controllers/easy_tokens/tokens_controller.rb', line 32

def update
  if @token.update(token_params)
    redirect_to tokens_path, notice: 'Token was successfully updated.'
  else
    render :edit
  end
end