Last active
December 30, 2015 23:39
-
-
Save kbaum/7902401 to your computer and use it in GitHub Desktop.
my portfolio optimized
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyPortfoliosController < ApplicationController | |
before_filter :authenticate_user! | |
helper_method :portfolio_spaces | |
helper_method :portfolio_properties | |
def show | |
end | |
private | |
def portfolio_properties | |
my_portfolio_filter.filtered_properties | |
end | |
def portfolio_spaces | |
my_portfolio_filter.filtered_spaces | |
end | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyPortfolioFilter | |
def filtered_spaces | |
@filtered_spaces ||= filtered_spaces_query(filtered_properties.collect(&:id)).includes(:videos, :property => :users) | |
end | |
def filtered_properties | |
@filtered_properties ||= user.my_properties.where(id: filtered_spaces_query.pluck(:property_id).uniq) | |
.includes(:city, :submarket, :photos, :videos, :spaces) | |
.page(page) | |
.per(10) | |
.decorate | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment