Answer the question
In order to leave comments, you need to log in
How to make an unusual association in simple_form (rails)?
Good afternoon.
There is a form for creating a trouble ticket:
<%= simple_form_for @request, html: {class: 'form-horizontal' } do |f| %>
<%= f.input :initiator, label: 'Инициатор' %>
<%= f.association :department, collection: Department.all, value_method: :id, label: 'Назначить на отдел' %>
<%= f.association :user, collection: User.all, label_method: :email, label: 'Ответственный' %>
<%= f.input :comment, label: 'Комментарий' %>
<%= f.input :sla, label: 'SLA' %>
<%= f.button :submit, label: 'Создать', class: "btn btn-primary" %>
<% end %>
Answer the question
In order to leave comments, you need to log in
Check out the Dynamic Select Menus screencast from railscasts.com , which does exactly what you need.
There is a newer version of the screencast, but a subscription is required. I have a new version, only xs where to upload it and whether it is necessary to download it on rutracker.
This can only be done with javascript, one of the options is to hang a handler on the first select on the 'change' event, which makes an AJAX request to the server, receives the necessary users and fills in the second select. Google ajax master-detail select boxes
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question