How to pass collection_select to simple gem form

0

Good community, I have a problem with the simple form gem, since I need to pass a colletion_select to a simple form, to do so gives a method error. I appreciate your help. Thanks!

    
asked by Leonard J. Ávila S. 20.08.2017 в 01:57
source

1 answer

0

Taking the example of your previous question :

<%= collection_select(:project, :name, @projects, :id, :name, prompt: "Seleciona proyecto") %>

You could do something like this:

<%= simple_form_for @object do |f| %>
   <%= f.input :project, collection: @projects, label_method: :name, value_method: :id, label: "Proyecto", include_blank: true %>
   <!-- Otros inputs -->
<% end %>

Where @object refers to the object you want to create in the form.

    
answered by 20.08.2017 / 02:17
source