has_one is poorly supported.  I'd probably do it in the permissions:

in comment model

belongs_to :post
belongs_to :user, :creator => true

def create_permitted?
  return false unless user.signed_up?
  return false if post.comments.*.user.includes? acting_user
  user_is? acting_user
end

Feel that second line needs a little breakdown...
post.comments (all comments belonging to this post - in other words, only 
ever make a new comment from a post so post is set)
[comment1, comment2, ...]
.*.user   - takes all the comments and runs the user method on them.  not 
the greatest approach but figured it'd be simpler than adding the sql
[user1, user2, ...]
.includes? acting_user

so, if the acting_user is in the list of post -> comments -> users, return 
false

last line, just to make sure created comments always belong to the 
acting_user.

-- 
You received this message because you are subscribed to the Google Groups "Hobo 
Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/hobousers?hl=en.

Reply via email to