rosa-build/app/controllers/platforms/key_pairs_controller.rb

30 lines
842 B
Ruby
Raw Normal View History

class Platforms::KeyPairsController < Platforms::BaseController
2012-07-13 12:18:12 +01:00
before_filter :authenticate_user!
load_and_authorize_resource :platform, :only => [:index]
load_and_authorize_resource :only => [:create, :destroy]
2012-07-13 12:18:12 +01:00
def create
@key_pair.user_id = current_user.id
2012-07-30 20:07:49 +01:00
if @key_pair.save
2012-07-13 12:18:12 +01:00
flash[:notice] = t('flash.key_pairs.saved')
else
flash[:error] = t('flash.key_pairs.save_error')
flash[:warning] = @key_pair.errors.full_messages.join('. ') unless @key_pair.errors.blank?
2012-07-13 12:18:12 +01:00
end
redirect_to platform_key_pairs_path(@key_pair.repository.platform)
2012-07-13 12:18:12 +01:00
end
def destroy
2012-07-30 20:07:49 +01:00
if @key_pair.destroy
2012-07-13 12:18:12 +01:00
flash[:notice] = t('flash.key_pairs.destroyed')
else
flash[:error] = t('flash.key_pairs.destroy_error')
end
redirect_to platform_key_pairs_path(@key_pair.repository.platform)
2012-07-13 12:18:12 +01:00
end
end