49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/home_page/navigation.rb', line 49
def self.(resource)
case resource
when :users
Proc.new do |primary, options|
if user_signed_in?
primary.item :users, I18n.t('users.index.title'), users_path do |users|
unless (@user.new_record? rescue true) || current_user.try(:id) == @user.id
if options[:after_resource_has_many]
instance_exec users, {}, &options[:after_resource_has_many]
end
end
end
end
end
when :authentication
Proc.new do |primary, options|
if user_signed_in?
primary.item :sign_out, I18n.t('authentication.sign_out'), destroy_user_session_path, method: :delete
else
primary.item :authentication, I18n.t('authentication.title'), new_user_session_path do |authentication|
authentication.item :sign_in, I18n.t('authentication.sign_in'), new_user_session_path
authentication.item :sign_up, I18n.t('authentication.sign_up'), new_user_registration_path
end
end
end
end
end
|