Skip to content
Snippets Groups Projects
Commit dcee32ae authored by Alexandre Peres Arias's avatar Alexandre Peres Arias
Browse files

fix rid passing from object and double complaint

parent 5ec7d3c4
No related branches found
No related tags found
No related merge requests found
......@@ -6,8 +6,8 @@ class ComplaintsController < ApplicationController
def create
@complaint = Complaint.new(complaint_params)
@complaint.user = current_user
@complaint.object = params[:object]
@complaint.object = params[:complaint][:object_rid]
respond_to do |format|
if complaint_repository.report @complaint
format.html { redirect_to @complaint, notice: 'complaint was successfully created.' }
......
......@@ -4,19 +4,18 @@ module OrientDb
include RepositoriesProxy
def report(complaint)
if edge_exists?(odb_class, complaint.user.id, complaint.object.id)
raise "The user has already been reported"
if edge_exists?(odb_class, complaint.user.rid, complaint.object)
raise "The object has already been reported by you."
end
connection.command "CREATE EDGE Complaint FROM #{complaint.user.id} TO #{complaint.object.id} SET message = #{complaint.message}, description = #{complaint.description}"
connection.command "CREATE EDGE Complaint FROM #{complaint.user.rid} TO #{complaint.object} SET message = #{complaint.message}, description = #{complaint.description}"
end
def destroy(object)
if !edge_exists?(odb_class, complaint.user.id, complaint.object.id)
raise "The user has not already been reported"
if !edge_exists?(odb_class, complaint.user.rid, complaint.object)
raise "The object has not been reported by you yet."
end
connection.command "DELETE EDGE Complaint FROM #{complaint.user.id} TO #{complaint.object.id}"
connection.command "DELETE EDGE Complaint FROM #{complaint.user.rid} TO #{complaint.object}"
end
def build_object(args={})
......
......@@ -21,7 +21,7 @@
</div>
<%= f.hidden_field :object, value: @learning_object %>
<%= f.hidden_field :object_rid, value: @learning_object.id %>
</fieldset>
<div align="center" class="ls-btn-primary">
......
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