Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

Untitled

a guest Mar 8th, 2018 56 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. def relateds_around
  2.     product_id = self.id
  3.     organization_id = self.organization.id
  4.     Relationship.find(:all) do
  5.       any do
  6.         all do
  7.           left_type == "Product"
  8.           left_id == product_id
  9.           right_type == "Place"
  10.         end
  11.        
  12.         all do
  13.           left_type == "Organization"
  14.           left_id == organization_id
  15.           right_type == "Place"
  16.         end
  17.        
  18.         all do
  19.           left_type == "Product"
  20.           left_id == product_id
  21.           right_type == "Event"
  22.         end
  23.        
  24.         all do
  25.           left_type == "Organization"
  26.           left_id == organization_id
  27.           right_type == "Event"
  28.         end
  29.       end
  30.     end.map(&:right).delete_if { |r| r.is_a?(Event) && r.past? }
  31.   end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top