Rails - creating multiple objects from one form -


I have a form that will update the attributes for one or several "treatment optimization" objects. Every one takes three properties, and a "work" is filled with the form every time the form is saved and used to create them - hidden area (: name), will be: adaptation_details (in the content work object) : Researcher / agency_leader/: Direct_provider will be: Car assigned_to on the other. Ingredients: symbol error:

Form:

  = form_tag update_individual_treatment_adaptations_path ,: I merge an undefined method `method = & gt; "Put" ,: id = & gt; "MyAdaptationsForm" do | F | | - current_agency.treatment_adaptations.order ('ASC created_at') = fields_for "treatment_adaptations []", do treatment_adaptations @for_treatment_adaptations. F | - If treatment_adaptations.not_doing_adaptation! = 'True'% tr% td = f.hidden_field: name ,: value = & gt; Treatment_adaptations.name% td = f.text_area: adaptation_details ,: content, rows = & gt; 10% TD = f.check_box: treatment_developer ,: researcher :: Treatment Developer% br = f.check_box assigned_to agency_leader ,: Supervisor :: agency leader% br = f.check_box assigned_to researcher% br = f.check_box assigned_to assigned_to supervisor % br = f.check_box: direct_provider ,: assigned_to direct supervisor% br = f.check_box: implementation_team ,: assigned_to direct supervisor% BR% br other:% br = f.text_area: other_implementer ,: assigned_to = submit_tag 'Save' category "Bitian Bitian-primary ' 

controller:

  def update_individual @task = @ current_agency.tasks.build (treatment_adaptations_params [: action]) @treatment_adaptations = TreatmentAdaptation. Update (parameter [: treatment_adaptations] .except (: function) .keys, parameter [: Treat_adaptations] .except (: functions) .values) .reject {| P | | P.errors.empty? } If @treatment_adaptations.empty? Set_flash "adaptations updated" redirect_to: back else set_flash "adaptation could not be updated" ,: error redirect_to: back end end personal def treatment_adaptations_params params.require (: treatment_adaptation) .permit (: org_level ,: provider_factors ,: client_chars ,: system_level ,: other_reasons ,: concerns ,: other_concerns ,: proceed_with_plan ,: seek_further_consultation ,: address_concern ,: address_concern_text ,: adaptation_details ,: treatment_developer ,: researcher ,: agency_leader ,: supervisor ,: direct_provider ,: implementation_team ,: other_implementer, task: [: Name, content: assigned_to])  

My solutions use an after_save callback Remedies for treatment / ed To make the erection model work like this, remove the required treatment_adaptation attributes.


Comments

Popular posts from this blog

c# - SignalR: "Protocol error: Unknown transport." when navigating to hub -

class - Kivy: how to instantiate a dynamic classes in python -

python - mayavi mapping a discrete colorbar on a surface -