Skip to content

Commit

Permalink
NewsItem scope shared between #show and #index
Browse files Browse the repository at this point in the history
  • Loading branch information
benichu committed Dec 5, 2015
1 parent 25c5fa0 commit 57c4060
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions app/controllers/news_items_controller.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
class NewsItemsController < ApplicationController
def index
@news_items = NewsItem.published.to_a
@news_items = news_item_scope.to_a
end

def show
@news_item = NewsItem.published.find(params[:id])
@news_item = news_item_scope.find(params[:id])
end

private

def news_item_scope
NewsItem.published
end
end

0 comments on commit 57c4060

Please sign in to comment.