collection_select issue ruby on rails -


i'm new ruby on rails , i've issue. in app, user can publish idea , ideas belongs activities. user can choose select activity want. here's code form, used collection_select

<div class="field"> <%=  collection_select(:idee, :id, activite.all, :id, :nom, prompt: true) %></div> 

the select input work, i've activities in select input when select activity , publish idea, idea don't take value , stay empty. when edit idea, idea don't take value of activity.

how can resolve ?

given have idea , activity model , building form idea, think should write collection_select as:

<%=  collection_select(:idea, :activity_id, activity.all, :id, :nom, prompt: true) %> 

i suggest use form_for syntax if not doing it.

check apidock reference: http://apidock.com/rails/actionview/helpers/formoptionshelper/collection_select

http://apidock.com/rails/actionview/helpers/formhelper/form_for


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -