0

I have an app set up where a user can nominate a keyholder who will have read-only access to some of their account. The keyholder is just a user with a keyholder boolean field set to true. They also have an access_id equal to the user_id of the account they can access.

Now what I am trying to do is have a link that points to the folders of the user from the keyholder's account, but I'm stumped how to write the link.

E.g.

<%= link_to 'Folder', folder_path(current_user.folder) %>

would link to their own folder, but how do I do:

<%= link_to 'Other User's Folder', folder_path(user.id = access_id) %>

if you see what I mean? Thanks!

ecs
  • 708
  • 1
  • 14
  • 33

1 Answers1

0

If I understand you correctly, it looks like you're looking for:

<%= link_to 'Others users folder', folder_path(User.find(current_user.access_id).folder) %>

Now there are better ways to do this. For example if you define the association between the two users in your User model:

belongs_to :access, :class_name => "User"

So now user.access points to the user that can the first one can access. Therefore you can do

<%= link_to 'Others users folder', folder_path(current_user.access.folder) %>
boulder
  • 3,256
  • 15
  • 21