#472: Update Platforms::TokensController
This commit is contained in:
parent
331d01040d
commit
b9e2f34239
|
@ -27,7 +27,7 @@ class Platforms::TokensController < Platforms::BaseController
|
|||
end
|
||||
|
||||
def create
|
||||
@token = @platform.tokens.build params[:token]
|
||||
@token = @platform.tokens.build token_params
|
||||
@token.creator = current_user
|
||||
authorize @token
|
||||
if @token.save
|
||||
|
@ -42,6 +42,10 @@ class Platforms::TokensController < Platforms::BaseController
|
|||
|
||||
protected
|
||||
|
||||
def token_params
|
||||
subject_params(Token)
|
||||
end
|
||||
|
||||
# Private: before_action hook which loads Repository.
|
||||
def load_token
|
||||
authorize @token = @platform.tokens.find(params[:id])
|
||||
|
|
|
@ -12,8 +12,6 @@ class Token < ActiveRecord::Base
|
|||
|
||||
before_validation :generate_token, on: :create
|
||||
|
||||
# attr_accessible :description
|
||||
|
||||
state_machine :status, initial: :active do
|
||||
event :block do
|
||||
transition [:active, :blocked] => :blocked
|
||||
|
|
|
@ -8,4 +8,11 @@ class TokenPolicy < ApplicationPolicy
|
|||
alias_method :read?, :show?
|
||||
alias_method :withdraw?, :show?
|
||||
|
||||
# Public: Get list of parameters that the user is allowed to alter.
|
||||
#
|
||||
# Returns Array
|
||||
def permitted_attributes
|
||||
%i(description)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue