Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
15 lines (12 sloc) 397 Bytes
class TodosController < ApplicationController
FILTERS = %w[all active completed].freeze
def index
session[:filter] = "all" unless filter_permitted?(session[:filter])
@all_todos = Todo.where(session_id: session.id)
@filtered_todos = @all_todos.public_send(session[:filter]).order(:created_at)
end
private
def filter_permitted?(filter)
FILTERS.include? filter
end
end
You can’t perform that action at this time.