Created
July 7, 2015 23:55
-
-
Save jackjennings/464bca48afdc2e925206 to your computer and use it in GitHub Desktop.
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 NewsItemsController < ApplicationController | |
include Dateable | |
has_scope :page, default: 1 | |
has_scope :year | |
def index | |
@year_range = NewsItem.year_range | |
@records = apply_scopes(default_scope) | |
respond_to do |format| | |
format.html | |
format.js { render('shared/load_more') } | |
end | |
end | |
def show | |
@news_item = NewsItem.find(params[:id]) | |
end | |
private | |
def default_scope | |
params.values_at(:exhibition_id) ? Exhibition.find(params[:exhibition_id]).news_items : NewsItem | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment