45 lines
1.1 KiB
Ruby
45 lines
1.1 KiB
Ruby
|
class Platforms::TokensController < ApplicationController
|
||
|
before_filter :authenticate_user!
|
||
|
|
||
|
# load_and_authorize_resource :platform
|
||
|
# load_and_authorize_resource #:token#, :through => :subject
|
||
|
# load_and_authorize_resource :token, :through => :subject
|
||
|
|
||
|
load_resource :platform
|
||
|
load_and_authorize_resource :through => :platform, :shallow => true
|
||
|
|
||
|
def index
|
||
|
@tokens = @platform.tokens.includes(:creator, :updater)
|
||
|
.paginate(:per_page => 20, :page => params[:page])
|
||
|
end
|
||
|
|
||
|
def show
|
||
|
end
|
||
|
|
||
|
def withdraw
|
||
|
if @token.block
|
||
|
redirect_to :back, :notice => t('layout.tokens.withdraw_success')
|
||
|
else
|
||
|
redirect_to :back, :notice => t('layout.tokens.withdraw_fail')
|
||
|
end
|
||
|
end
|
||
|
|
||
|
def new
|
||
|
|
||
|
end
|
||
|
|
||
|
def create
|
||
|
@token = @platform.tokens.build params[:token]
|
||
|
@token.creator = current_user
|
||
|
if @token.save
|
||
|
flash[:notice] = t('flash.tokens.saved')
|
||
|
redirect_to platform_tokens_path(@platform)
|
||
|
else
|
||
|
flash[:error] = t('flash.tokens.save_error')
|
||
|
flash[:warning] = @token.errors.full_messages.join('. ') unless @token.errors.blank?
|
||
|
render :new
|
||
|
end
|
||
|
end
|
||
|
|
||
|
end
|