Class: Api::V1::PrayersController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/api/v1/prayers_controller.rb

Overview

The Api:V1:PrayersController provides a backend API for manipulating prayer requests.

Author:

  • Robert Klubenspies

Since:

  • 0.1.0

Instance Method Summary collapse

Instance Method Details

#createObject

TODO:

Make the create action actually persist data

Creates a prayer request

Author:

  • Robert Klubenspies

Since:

  • 0.1.0



34
35
# File 'app/controllers/api/v1/prayers_controller.rb', line 34

def create
end

#indexObject

Retrieves a feed of 10 prayer requests at a time

Author:

  • Robert Klubenspies

Since:

  • 0.1.0



12
13
14
15
16
17
18
# File 'app/controllers/api/v1/prayers_controller.rb', line 12

def index
  # Determine when the oldest prayer's timestamp from params[:last] OR use the current time + 1 second
  @last = params[:last].blank? ? Time.now.utc + 1.second : Time.parse(params[:last])
  
  # Retrieve 10 prayer requests based on the timestamp
  @prayers = Prayer.feed(@last)
end

#showObject

Retrieves a single prayer request

Author:

  • Robert Klubenspies

Since:

  • 0.1.0



24
25
26
27
# File 'app/controllers/api/v1/prayers_controller.rb', line 24

def show
  # Retrieve prayer request by params[:id]
  @prayer = Prayer.find(params[:id])
end