#472: Update Platforms::TokensController

This commit is contained in:
Vokhmin Alexey V 2015-05-21 00:52:50 +03:00
parent 331d01040d
commit b9e2f34239
3 changed files with 12 additions and 3 deletions

View File

@ -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])

View File

@ -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

View File

@ -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