Commit d0546e6d authored by James Lopez's avatar James Lopez

uypdated keys controller logic

parent 72b7b10d
...@@ -11,10 +11,10 @@ class Profiles::KeysController < Profiles::ApplicationController ...@@ -11,10 +11,10 @@ class Profiles::KeysController < Profiles::ApplicationController
end end
def create 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? if @key.persisted?
redirect_to_profile_key_path redirect_to profile_key_path(@key)
else else
@keys = current_user.keys.select(&:persisted?) @keys = current_user.keys.select(&:persisted?)
render :index render :index
...@@ -50,12 +50,6 @@ class Profiles::KeysController < Profiles::ApplicationController ...@@ -50,12 +50,6 @@ class Profiles::KeysController < Profiles::ApplicationController
end end
end end
protected
def redirect_to_profile_key_path
redirect_to profile_key_path(@key)
end
private private
def key_params def key_params
......
...@@ -4,6 +4,7 @@ module Keys ...@@ -4,6 +4,7 @@ module Keys
def initialize(user, params) def initialize(user, params)
@user, @params = user, params @user, @params = user, params
@ip_address = @params.delete(:ip_address)
end end
def notification_service def notification_service
......
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