samedi 17 juin 2017

Why show undefined on rails select?

i have a ajax select on a rails app that is showing undefined on select like the screeshot attached

i changed the order to fix but if i remove the order did not show, and if i put create_at or by name asc show this undefined

someone know why?

the on controller is:

 def index
          genders = Gender.where(block_id: params[:block_id]).select('id, gender').order('created_at asc')
          render json: genders
        end

in the view is:

<%=dynamic_collection_select :product, :gender_id, :category, [], :id, :gender, { include_blank: false, submit_with_form: true, :prompt=> 'Select' }, { class: 'form-control select_item' } %>

enter image description here

Aucun commentaire:

Enregistrer un commentaire