I think my problem is really small, but I didn't found a good solution in the internet.
<%= form_tag url_for(controller: 'courses', action: 'add_teacher') , method: 'put' do%>
<%= select_tag :teacher, options_for_select(Teacher.all.collect {|t| ([t._name, t.id] unless @course.teachers.include?(t))})%>
<%= hidden_field_tag(:course, value = @course.id) %>
<%= submit_tag 'hinzufügen' %>
I got this code in my courses/new View. I would like to add one or more teachers for one course, but i don't want to be able to add them twice or more. So I used this:
unless @course.teachers.include?(t)
The problem is, it still looks like this:empty rows
May anyone got a better solution for this problem? what happens if teachers = nil?
thank u for help
autocomplete
method on the controller and on the frontend there's plenty of javascript libraries for the job. – Thomas R. Koll