Created
August 19, 2016 17:32
-
-
Save aristotelesbr/5f5f1ebb62cf07e031cd5ddefdb340b1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@examination_request | |
=> #<ExaminationRequest:0x002ab3b2f7fd38> { | |
:id => 1, | |
:procedure_type => "", | |
:execultante_sector => "", | |
:patient_id => nil, | |
:user_id => nil, | |
:medical_consultation_id => nil, | |
:created_at => Fri, 19 Aug 2016 14:58:07 UTC +00:00, | |
:updated_at => Fri, 19 Aug 2016 14:58:07 UTC +00:00 | |
} | |
----------------------------------------------------------------------- | |
@examination_request.procedures | |
=> [ | |
[0] #<Procedure:0x002ab3b1d97b20> { | |
:id => 1, | |
:procedure_file_id => 1, | |
:amount => 1, | |
:examination_request_id => 1, | |
:created_at => Fri, 19 Aug 2016 15:05:52 UTC +00:00, | |
:updated_at => Fri, 19 Aug 2016 15:05:52 UTC +00:00 | |
}, | |
[1] #<Procedure:0x002ab3b1d979e0> { | |
:id => 2, | |
:procedure_file_id => 1, | |
:amount => 10, | |
:examination_request_id => 1, | |
:created_at => Fri, 19 Aug 2016 15:09:57 UTC +00:00, | |
:updated_at => Fri, 19 Aug 2016 15:09:57 UTC +00:00 | |
} | |
] | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def update | |
if @examination_request.update_attributes(examination_request_params) | |
# Também estou tentando algo como: | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def | |
has_many :procedures | |
has_many :procedure_file, through: :procedures | |
has_many :procedures, dependent: :destroy | |
accepts_nested_attributes_for :procedures, allow_destroy: true, update_only: true | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
params | |
=> { | |
"utf8" => "✓", | |
"_method" => "patch", | |
"authenticity_token" => "Qtin1tWaOolJITf41POjmRT/6CcGglZzq45nOtkAFUHVVRB0MU0j2BQuf+gOee4LO3sDLdOcGckKIX2NjQachQ==", | |
"examination_request" => { | |
"procedure_type" => "Teste maroto", | |
"execultante_sector" => "1", | |
"patient_id" => "", | |
"user_id" => "", | |
"procedures_attributes" => { | |
"0" => { | |
"procedure_file_id" => "1", | |
"amount" => "1", | |
"_destroy" => "1", | |
"id" => "1" | |
}, | |
"1" => { | |
"procedure_file_id" => "1", | |
"amount" => "5", | |
"_destroy" => "false", | |
"id" => "2" | |
} | |
} | |
}, | |
"commit" => "Salvar", | |
"controller" => "examination_requests", | |
"action" => "update", | |
"id" => "1" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment