Extract profile route helpers to a module

element
Marcin Kulik 9 years ago
parent a44121eb7b
commit 9881c5df6c

@ -4,6 +4,7 @@ module Api
class BaseController < ActionController::Base
include WardenAuthentication
include RouteHelper
private

@ -69,18 +69,6 @@ class ApplicationController < ActionController::Base
end
end
def profile_path(user)
if user.username
public_profile_path(username: user.username)
else
unnamed_user_path(user)
end
end
def profile_url(user)
root_url[0..-2] + profile_path(user)
end
helper_method :profile_path, :profile_url
include RouteHelper
end

@ -0,0 +1,15 @@
module RouteHelper
def profile_path(user)
if user.username
public_profile_path(username: user.username)
else
unnamed_user_path(user)
end
end
def profile_url(user)
root_url[0..-2] + profile_path(user)
end
end
Loading…
Cancel
Save