uypdated keys controller logic

This commit is contained in:
James Lopez 2017-10-24 09:52:47 +03:00
parent 72b7b10d52
commit d0546e6d81
2 changed files with 3 additions and 8 deletions

View File

@ -11,10 +11,10 @@ class Profiles::KeysController < Profiles::ApplicationController
end
def create
@key = Keys::CreateService.new(current_user, key_params).execute
@key = Keys::CreateService.new(current_user, key_params.merge(ip_address: request.remote_ip)).execute
if @key.persisted?
redirect_to_profile_key_path
redirect_to profile_key_path(@key)
else
@keys = current_user.keys.select(&:persisted?)
render :index
@ -50,12 +50,6 @@ class Profiles::KeysController < Profiles::ApplicationController
end
end
protected
def redirect_to_profile_key_path
redirect_to profile_key_path(@key)
end
private
def key_params

View File

@ -4,6 +4,7 @@ module Keys
def initialize(user, params)
@user, @params = user, params
@ip_address = @params.delete(:ip_address)
end
def notification_service