Scope querying in PhotosController#show
This commit is contained in:
parent
5fa2a7a6f3
commit
e3ad078ba5
2 changed files with 5 additions and 5 deletions
|
|
@ -139,7 +139,7 @@ class PhotosController < ApplicationController
|
|||
end
|
||||
|
||||
def show
|
||||
@photo = current_user.find_visible_post_by_id(params[:id])
|
||||
@photo = current_user.find_visible_post_by_id(params[:id], :type => 'Photo')
|
||||
if @photo
|
||||
@parent = StatusMessage.where(:id => @photo.status_message_id).includes(:photos).first if @photo.status_message_id
|
||||
|
||||
|
|
|
|||
|
|
@ -6,10 +6,10 @@ module Diaspora
|
|||
module UserModules
|
||||
module Querying
|
||||
|
||||
def find_visible_post_by_id( id )
|
||||
post = Post.where(:id => id).joins(:contacts).where(:contacts => {:user_id => self.id}).first
|
||||
post ||= Post.where(:id => id, :author_id => self.person.id).first
|
||||
post ||= Post.where(:id => id, :public => true).first
|
||||
def find_visible_post_by_id( id, opts={} )
|
||||
post = Post.where(:id => id).joins(:contacts).where(:contacts => {:user_id => self.id}).where(opts).first
|
||||
post ||= Post.where(:id => id, :author_id => self.person.id).where(opts).first
|
||||
post ||= Post.where(:id => id, :public => true).where(opts).first
|
||||
end
|
||||
|
||||
def raw_visible_posts(opts = {})
|
||||
|
|
|
|||
Loading…
Reference in a new issue