This is how my database should be laid out.
User (one) => many Computers (one) => many Accounts
I am trying to set up CanCan so that only the owner of the computer can edit an account. This is what I have so far.
user ||= User.new
if user.admin?
can :manage, :all
else
can :manage, Computer, :user_id => user.id # <= works
can :manage, Account, :computer => {:user_id => user.id} # <= doesnt work
end
The second can does not work. I would like it so that I can have a user be able to edit all the accounts associated with all of his computers. Any ideas to why this isn’t working?
I have tried implementing some of the ways that the guide says to but those aren’t working either.
I had a similar situation and was able to make it work with:
So, basically, the user can manage accounts that have computer_ids associated to the user.