Add :owner marker to belongs_to, for easier permissions checking
Reported by Matt Jones | October 23rd, 2009 @ 09:19 AM | in Beyond Hobo 1.0
And a corresponding helper (maybe owned_by?(user)) to clean up a common permission case.
class Foo < ActiveRecord::Base
hobo_model
belongs_to :some_model, :owner => true
def update_permitted?
acting_user.administrator? || owned_by?(acting_user)
end
end
It might even make sense to roll a none_changed?(:some_model_id) into owned_by.
Comments and changes to this ticket
-
Tom Locke October 24th, 2009 @ 05:51 PM
- Milestone set to Beyond Hobo 1.0
I wrestled for a while early on with whether to go with 'creators' or 'owners'. As you know we ended up with support for creators but not owners. The two overlap a lot but are subtly different. Is there a way we can handle the two together in some way?
Either way I think we'll call this a beyond-1.0, but lets discuss
-
Tom Locke October 24th, 2009 @ 06:10 PM
- State changed from new to open
-
Bryan Larsen October 29th, 2009 @ 11:17 PM
- Tag set to enhancement, permissions
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป