Class: SocialNetworking::NudgesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/social_networking/nudges_controller.rb

Overview

Manage Nudges.

Constant Summary

Constants inherited from ApplicationController

ApplicationController::CSRF_COOKIE_NAME, ApplicationController::CSRF_HEADER_NAME

Instance Method Summary collapse

Instance Method Details

#createObject



15
16
17
18
19
20
21
22
23
24
# File 'app/controllers/social_networking/nudges_controller.rb', line 15

def create
  @nudge = Nudge.new(sanitized_params)

  if @nudge.save
    build_notification.notify
    render json: { message: "Nudge sent!" }
  else
    render json: { error: model_errors }, status: 400
  end
end

#indexObject



10
11
12
13
# File 'app/controllers/social_networking/nudges_controller.rb', line 10

def index
  @nudges = Nudge.search(sanitized_params[:recipient_id])
  render json: Serializers::NudgeSerializer.from_collection(@nudges)
end