Skip to content

Commit

Permalink
Fix members routes
Browse files Browse the repository at this point in the history
  • Loading branch information
enricostano committed Aug 16, 2017
1 parent 980cd1f commit a56dab6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
11 changes: 8 additions & 3 deletions app/helpers/users_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def users_as_json
balance: membership.account_balance.to_i,

url: organization_user_path(organization_id: membership.organization_id, id: user.id),
edit_link: edit_user_path(user),
edit_link: edit_link(membership),
cancel_link: cancel_member_path(membership),
toggle_manager_link: toggle_manager_member_path(membership),
manager: !!membership.manager,
Expand All @@ -29,8 +29,13 @@ def users_as_json

private

def edit_user_path(user)
can_edit_user?(user) ? super : ""
def edit_link(membership)
return '' unless can_edit_user?(membership.user)

edit_organization_user_path(
organization_id: membership.organization_id,
id: membership.user_id
)
end

def can_edit_user?(user)
Expand Down
4 changes: 1 addition & 3 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

get "global/switch_lang", as: :switch_lang

resources :users, only: [:show, :edit]

concern :accountable do
get :give_time, on: :member
end
Expand All @@ -21,7 +19,7 @@
# TODO: 'members' path is misleading, there is already a resource called 'members'
resources :users,
concerns: :accountable,
except: [:show, :edit, :destroy],
except: [:destroy],
path: 'members'
resources :inquiries
resources :offers
Expand Down

0 comments on commit a56dab6

Please sign in to comment.