Take out default scopes

This commit is contained in:
Raphael 2011-01-18 16:46:35 -08:00
parent ef1b7644f3
commit e6e2ba9cfb
6 changed files with 11 additions and 14 deletions

View file

@ -11,7 +11,7 @@ class AspectsController < ApplicationController
def index
if params[:a_ids]
@aspects = current_user.aspects.where(:id => params[:a_ids]).includes(:contacts) #linit 16
@aspects = current_user.aspects.where(:id => params[:a_ids]).includes(:contacts)
else
@aspects = current_user.aspects.includes(:contacts)
end
@ -25,7 +25,7 @@ class AspectsController < ApplicationController
post_ids = @aspects.map{|a| a.post_ids}.flatten!
@posts = StatusMessage.joins(:aspects).where(:pending => false,
:aspects => {:id => @aspect_ids}).includes(:person, :comments, :photos).select('DISTINCT `posts`.*').paginate(
:aspects => {:id => @aspect_ids}).includes(:person, :comments => :person, :photos).select('DISTINCT `posts`.*').paginate(
:page => params[:page], :per_page => 15, :order => 'created_at DESC')
@contacts = current_user.contacts.includes(:person).where(:pending => false)
@ -70,13 +70,13 @@ class AspectsController < ApplicationController
end
def show
@aspect = current_user.aspects.where(:id => params[:id]).first
@aspect = current_user.aspects.where(:id => params[:id]).includes(:contacts => :person).first
redirect_to aspects_path('a_ids[]' => @aspect.id)
end
def edit
@aspect = current_user.aspects.where(:id => params[:id]).includes(:contacts).first
@contacts = current_user.contacts.where(:pending => false)
@aspect = current_user.aspects.where(:id => params[:id]).first
@contacts = current_user.contacts.includes(:person).where(:pending => false)
unless @aspect
render :file => "#{Rails.root}/public/404.html", :layout => false, :status => 404
else
@ -88,9 +88,9 @@ class AspectsController < ApplicationController
def manage
@aspect = :manage
@contacts = current_user.contacts.where(:pending => false)
@contacts = current_user.contacts.includes(:person).where(:pending => false)
@remote_requests = Request.where(:recipient_id => current_user.person.id)
@aspects = @all_aspects.includes(:contacts)
@aspects = @all_aspects.includes(:contacts => :person)
end
def update

View file

@ -135,7 +135,7 @@ class PhotosController < ApplicationController
end
def show
@photo = current_user.visible_photos.where(:id => params[:id]).first
@photo = current_user.visible_photos.where(:id => params[:id]).includes(:person, :status_message => :photos).first
if @photo
@parent = @photo.status_message
@ -152,8 +152,8 @@ class PhotosController < ApplicationController
end
@object_aspect_ids = []
if @parent.aspects
@object_aspect_ids = @parent.aspects.map{|a| a.id}
if @parent_aspects = @parent.aspects.where(:user_id => current_user.id)
@object_aspect_ids = @parent_aspects.map{|a| a.id}
end
@ownership = current_user.owns? @photo

View file

@ -9,7 +9,7 @@ class PostsController < ApplicationController
skip_before_filter :set_locale
def show
@post = Post.where(:id => params[:id], :public => true).first
@post = Post.where(:id => params[:id], :public => true).includes(:person, :comments => :person).first
if @post
@landing_page = true

View file

@ -3,7 +3,6 @@
# the COPYRIGHT file.
class Comment < ActiveRecord::Base
default_scope :include => :person
require File.join(Rails.root, 'lib/diaspora/web_socket')
require File.join(Rails.root, 'lib/youtube_titles')
include YoutubeTitles

View file

@ -3,7 +3,6 @@
# the COPYRIGHT file.
class Contact < ActiveRecord::Base
default_scope :include => :person
belongs_to :user
validates_presence_of :user

View file

@ -3,7 +3,6 @@
# the COPYRIGHT file.
class Post < ActiveRecord::Base
default_scope :include => [:person, :comments]
require File.join(Rails.root, 'lib/encryptable')
require File.join(Rails.root, 'lib/diaspora/web_socket')
include ApplicationHelper