Hello, I'm trying to work with nested models in a form view and it's not going so smoothly. A user has many lawyers and a lawyer can take many services. I want a checkbox on which the user can select the services of each lawyer. How can I do it? This is what I've got so far:
<%= form_for @user do |f| %> <%= f.label :email %><%= f.email_field :email %> .... <% @user.lawyers.each do |lawyer| %> <%= f.fields_for :lawyers, lawyer do |lf| %> <%= lf.label :name, "Nome: " %><%= lf.text_field :name %> <!-- Everything is working fine so far. However, I can get this to work. A lawyer can have many services: --> <% Service.all.each do |service| %> <%= check_box_tag ???, service.id, lawyer.services.include?(service) %> <% end %> <% end %> <% end %> <% end %> -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/ihBN0tL0JToJ. For more options, visit https://groups.google.com/groups/opt_out.