Sebastian Edler


60 Experience
0 Lessons Completed
0 Questions Solved


Posted in Nested attributes permit


thank you for your reply.

Unfortunately that seems to be xactly what I have as my code to build the Form
Here is my form.html.erb. I cut out the unnessesary fields, as well as the error handling:

<%= form_with scope: :customer, url: customers_path, local: true  do |form|%>

    <%= form.label :name %>
    <%= form.text_field :name%>

    <%= form.fields_for :mails do |mf| %>
      <%= mf.label :mailaddress %>
      <%= mf.text_field :mailaddress %>
    <% end %>

    <%= form.submit %>

<% end %>

Posted in Nested attributes permit

Hey out there,

i am sorry to bother you with my stupid question, but it is important for me, and unfortunately I am not able to find an answer myself.

I have tried to conduct the documentation, but I am unable to find a helpful (to me) anwer. --> 4.5.2 "nested parameters"

I try to safe a data for two different models, in one go. I use the accepts_nested_attributes_for in the parrent class, and I am able to get the parameters:

Parameters: {"utf8"=>"✓", "authenticity_token"=>"-cut-", "customer"=>
{"name"=>"2222", "city"=>"2222222", "mails"=>{"mailaddress"=>"22222222"}}, "commit"=>"Save Customer"}

But I get en error message:
Unpermitted parameter: :mails

I tried to whitelist the parameters ... but without success:

    def customer_params
        :name, :city,
        :mails_attributes => [:mailaddress])

What have I done wrong?

Thanks for taking a look!

Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more.

© 2023 GoRails, LLC. All rights reserved.