Commit ecbc11a8 authored by Alexis Reigel's avatar Alexis Reigel

extract setter as before_action

parent 98531fc2
class Profiles::GpgKeysController < Profiles::ApplicationController class Profiles::GpgKeysController < Profiles::ApplicationController
before_action :set_gpg_key, only: [:destroy, :revoke]
def index def index
@gpg_keys = current_user.gpg_keys @gpg_keys = current_user.gpg_keys
@gpg_key = GpgKey.new @gpg_key = GpgKey.new
...@@ -16,8 +18,7 @@ class Profiles::GpgKeysController < Profiles::ApplicationController ...@@ -16,8 +18,7 @@ class Profiles::GpgKeysController < Profiles::ApplicationController
end end
def destroy def destroy
@gpp_key = current_user.gpg_keys.find(params[:id]) @gpg_key.destroy
@gpp_key.destroy
respond_to do |format| respond_to do |format|
format.html { redirect_to profile_gpg_keys_url, status: 302 } format.html { redirect_to profile_gpg_keys_url, status: 302 }
...@@ -26,8 +27,7 @@ class Profiles::GpgKeysController < Profiles::ApplicationController ...@@ -26,8 +27,7 @@ class Profiles::GpgKeysController < Profiles::ApplicationController
end end
def revoke def revoke
@gpp_key = current_user.gpg_keys.find(params[:id]) @gpg_key.revoke
@gpp_key.revoke
respond_to do |format| respond_to do |format|
format.html { redirect_to profile_gpg_keys_url, status: 302 } format.html { redirect_to profile_gpg_keys_url, status: 302 }
...@@ -40,4 +40,8 @@ class Profiles::GpgKeysController < Profiles::ApplicationController ...@@ -40,4 +40,8 @@ class Profiles::GpgKeysController < Profiles::ApplicationController
def gpg_key_params def gpg_key_params
params.require(:gpg_key).permit(:key) params.require(:gpg_key).permit(:key)
end end
def set_gpg_key
@gpg_key = current_user.gpg_keys.find(params[:id])
end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment