Browse Source

Use deep_symbolize_keys with to_unsafe_h

pull/9/head
Angel Aviel Domaoan 4 years ago committed by Angel Aviel Domaoan
parent
commit
0250f243db
  1. 4
      app/controllers/doctrine/annotations_controller.rb
  2. 4
      app/controllers/jurisprudence/doctrines_controller.rb

4
app/controllers/doctrine/annotations_controller.rb

@ -3,7 +3,7 @@ class Doctrine::AnnotationsController < ApplicationController
load_and_authorize_resource :annotation, class: "Annotation", through: :doctrine load_and_authorize_resource :annotation, class: "Annotation", through: :doctrine
def create def create
attrs = resource_params.to_unsafe_h attrs = resource_params.to_unsafe_h.deep_symbolize_keys
document_id = attrs.delete(:document_id) document_id = attrs.delete(:document_id)
@annotation = @doctrine.annotations.new(attrs) @annotation = @doctrine.annotations.new(attrs)
@ -22,7 +22,7 @@ class Doctrine::AnnotationsController < ApplicationController
end end
def update def update
attrs = resource_params.to_unsafe_h attrs = resource_params.to_unsafe_h.deep_symbolize_keys
document_id = attrs.delete(:document_id) document_id = attrs.delete(:document_id)
attrs[:document] = Cdao::Jurisprudence.find(document_id) if document_id.present? attrs[:document] = Cdao::Jurisprudence.find(document_id) if document_id.present?

4
app/controllers/jurisprudence/doctrines_controller.rb

@ -3,7 +3,7 @@ class Jurisprudence::DoctrinesController < ApplicationController
load_and_authorize_resource :doctrine, class: "Doctrine", through: :jurisprudence load_and_authorize_resource :doctrine, class: "Doctrine", through: :jurisprudence
def create def create
attrs = resource_params.to_unsafe_h attrs = resource_params.to_unsafe_h.deep_symbolize_keys
subject_ids = attrs.delete(:subject_ids) subject_ids = attrs.delete(:subject_ids)
@doctrine = @jurisprudence.doctrines(attrs) @doctrine = @jurisprudence.doctrines(attrs)
@ -20,7 +20,7 @@ class Jurisprudence::DoctrinesController < ApplicationController
end end
def update def update
attrs = resource_params.to_unsafe_h attrs = resource_params.to_unsafe_h.deep_symbolize_keys
subject_ids = attrs.delete(:subject_ids) subject_ids = attrs.delete(:subject_ids)
respond_to do |format| respond_to do |format|

Loading…
Cancel
Save