1
0
Fork 0

Scope to not list self in users list

This commit is contained in:
Andrew Tomaka 2014-11-14 22:07:41 -05:00
parent 01d6c0e97d
commit f592c80aaf
2 changed files with 3 additions and 1 deletions

View file

@ -1,6 +1,6 @@
class UsersController < ApplicationController class UsersController < ApplicationController
def index def index
@users = User.all @users = User.all_except(current_user)
end end
def show def show

View file

@ -2,6 +2,8 @@ class User < ActiveRecord::Base
has_many :friendships has_many :friendships
has_many :friends, through: :friendships has_many :friends, through: :friendships
scope :all_except, ->(user) { where.not(id: user) }
def self.from_omniauth(auth) def self.from_omniauth(auth)
where(provider: auth[:provider], uid: auth[:uid]).first_or_create do |user| where(provider: auth[:provider], uid: auth[:uid]).first_or_create do |user|
user.provider = auth[:provider] user.provider = auth[:provider]