Class: VotesController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/votes_controller.rb

Overview

Handling votes

Instance Method Summary collapse

Instance Method Details

#createObject

post /votes



8
9
10
11
12
13
14
15
# File 'app/controllers/votes_controller.rb', line 8

def create
  @entity = Vote.new(creation_parameters)
  if @entity.votable.vote_applicable?(@entity)
    process_vote
  else
    render :result, status: :unprocessable_entity
  end
end

#destroyObject

delete /votes/:id



18
19
20
21
# File 'app/controllers/votes_controller.rb', line 18

def destroy
  @entity.destroy
  render :result
end