Skip to content

Instantly share code, notes, and snippets.

@jackjennings
Created July 7, 2015 23:55
Show Gist options
  • Save jackjennings/464bca48afdc2e925206 to your computer and use it in GitHub Desktop.
Save jackjennings/464bca48afdc2e925206 to your computer and use it in GitHub Desktop.
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