Scope to not list self in users list
This commit is contained in:
parent
01d6c0e97d
commit
f592c80aaf
2 changed files with 3 additions and 1 deletions
|
@ -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
|
||||||
|
|
|
@ -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]
|
||||||
|
|
Loading…
Reference in a new issue