daily pastebin goal
16%
SHARE
TWEET

Untitled

a guest Jan 19th, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. User.rb (id,name)
  2.     default_scope :conditions => 'users.deleted_at IS NULL'
  3.  
  4. NavItem.rb (id,user_id, friend_id)
  5.  
  6. items = NavItem.find_all_by_user_id(current_user.id)
  7. items.each do |item|
  8.     user = User.find(item.friend_id)
  9. end
  10.    
  11. class User < ActiveRecord::Base
  12.   attr_accessible :deleted_at, :name
  13.  
  14.   default_scope :conditions => 'users.deleted_at IS NULL'
  15.  
  16.   has_many :nav_items
  17. end
  18.  
  19.  
  20. class NavItem < ActiveRecord::Base
  21.   attr_accessible :friend_id, :user_id
  22.  
  23.   belongs_to :user
  24.  
  25.   scope :without_deleted_users, where(:user_id => User.scoped)
  26. end
  27.    
  28. NavItem.without_deleted_users
  29.   NavItem Load (0.2ms)  SELECT "nav_items".* FROM "nav_items" WHERE "nav_items"."user_id" IN (SELECT "users"."id" FROM "users" WHERE (users.deleted_at IS NULL))
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