Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
def shared_to?(object, by_user=nil)
shareable = ActiveRecord::Base.send(:class_name_of_active_record_descendant, self.class).to_s
to = ActiveRecord::Base.send(:class_name_of_active_record_descendant, object.class).to_s
if by_user
s = Share.find(:first, :conditions=>["shareable_type = ? and shareable_id = ? and shared_to_type = ? and shared_to_id = ? and user_id=?",
shareable, id, to, object.id, by_user.id])
else
s = Share.find(:first, :conditions=>["shareable_type = ? and shareable_id = ? and shared_to_type = ? and shared_to_id = ?",
shareable, id, to, object.id])
end
return !s.nil?
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.