Skip to content
Snippets Groups Projects
Commit f0c634f7 authored by Mateus Rambo Strey's avatar Mateus Rambo Strey
Browse files

fix complaint controller

parent cca7012b
No related branches found
No related tags found
No related merge requests found
class ComplaintsController < ApplicationController
before_action :set_complaint, only: [:show, :update, :destroy, :like]
# POST /complaints
# POST /complaints.json
def create
@complaint = Complaint.new(complaint_params)
@complaint.user = current_user
@complaint.object = params[:complaint][:object_rid]
respond_to do |format|
if complaint_repository.report @complaint
format.html { redirect_to :back, notice: 'Denúncia realizada com sucesso.' }
else
format.html { redirect_to :back, alert: 'Objeto já foi denunciado por você.' }
end
end
end
# DELETE /complaints/1
# DELETE /complaints/1.json
def destroy
complaint_repository.destroy @complaint
respond_to do |format|
format.html { redirect_to complaints_url, notice: 'Complaint was successfully destroyed.' }
end
end
private
def set_complaint
@complaint = complaint_repository.find params[:id]
end
# Never trust parameters from the scary internet, only allow the white list through.
def complaint_params
params.require(:complaint).permit(:object, :message, :description)
end
end
......@@ -2,7 +2,6 @@ class Management::ComplaintsController < ManagementController
include RepositoriesProxy
def index
end
def show
......@@ -14,6 +13,20 @@ class Management::ComplaintsController < ManagementController
end
end
def create
@complaint = Complaint.new(complaint_params)
@complaint.user = current_user
@complaint.object = params[:complaint][:object_rid]
respond_to do |format|
if complaint_repository.report @complaint
format.html { redirect_to :back, notice: 'Denúncia realizada com sucesso.' }
else
format.html { redirect_to :back, alert: 'Objeto já foi denunciado por você.' }
end
end
end
def destroy
object_rid = params["object_rid"]
......@@ -26,4 +39,11 @@ class Management::ComplaintsController < ManagementController
end
private
# Never trust parameters from the scary internet, only allow the white list through.
def complaint_params
params.require(:complaint).permit(:object, :message, :description)
end
end
<%= form_for @complaint do |f| %>
<%= form_for [:management, @complaint] do |f| %>
<fieldset>
<div class="ls-label " >
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment