From b9e2f342394e44aef692e81160fe7e544100242d Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Thu, 21 May 2015 00:52:50 +0300 Subject: [PATCH] #472: Update Platforms::TokensController --- app/controllers/platforms/tokens_controller.rb | 6 +++++- app/models/token.rb | 2 -- app/policies/token_policy.rb | 7 +++++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/controllers/platforms/tokens_controller.rb b/app/controllers/platforms/tokens_controller.rb index 16b662a90..38faaf88a 100644 --- a/app/controllers/platforms/tokens_controller.rb +++ b/app/controllers/platforms/tokens_controller.rb @@ -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]) diff --git a/app/models/token.rb b/app/models/token.rb index bcf14674d..cbd7520c5 100644 --- a/app/models/token.rb +++ b/app/models/token.rb @@ -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 diff --git a/app/policies/token_policy.rb b/app/policies/token_policy.rb index 23ace1dc8..09e1edc2c 100644 --- a/app/policies/token_policy.rb +++ b/app/policies/token_policy.rb @@ -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