Class: Bible270::ReadersController
Constant Summary
ApplicationController::REMEMBER_COOKIE
Instance Method Summary
collapse
Instance Method Details
#clear_start_date ⇒ Object
36
37
38
39
40
41
42
43
44
45
|
# File 'app/controllers/bible270/readers_controller.rb', line 36
def clear_start_date
return unless require_reader!
if Bible270.config.allow_reader_start_date
current_reader.clear_start_date!
redirect_to root_path, notice: 'Start date cleared — the plan is now undated for you.'
else
redirect_to root_path, alert: 'The start date is set for the whole community.'
end
end
|
#index ⇒ Object
5
6
7
8
9
10
11
|
# File 'app/controllers/bible270/readers_controller.rb', line 5
def index
@readers = Reader.all.to_a
counts = Checkoff.group(:reader_id, :day).count
@days_completed = Hash.new(0)
counts.each { |(rid, day), n| @days_completed[rid] += 1 if n >= Plan.total_parts(day) }
@readers.sort_by! { |r| [-@days_completed[r.id], r.display_name.to_s] }
end
|
#show ⇒ Object
13
14
15
16
17
18
19
|
# File 'app/controllers/bible270/readers_controller.rb', line 13
def show
@reader = Reader.find_by(id: params[:id])
redirect_to(, alert: 'Reader not found.') and return unless @reader
@days_completed = @reader.days_completed
@recent_comments = @reader..recent.limit(20)
end
|
#update_start_date ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'app/controllers/bible270/readers_controller.rb', line 21
def update_start_date
return unless require_reader!
unless Bible270.config.allow_reader_start_date
redirect_to(root_path, alert: 'The start date is set for the whole community.') and return
end
if current_reader.update_start_date!(params[:start_date])
redirect_to root_path,
notice: "Start date set to #{current_reader.started_on.strftime('%B %-d, %Y')}."
else
redirect_to root_path, alert: "That doesn't look like a valid date."
end
end
|