i am new to ruby on rails, and this might be a simple one but i have
no idea what to do.
i need to put a select (_tag or whatever) into a list.rhtml and get
the selected value from this. Putting the select to the view works
fine. The displayed options are ok too, but i don't know how to get
the selected option. What i have so far:
<% for column in Calendar.content_columns %>
<td><%=h calendar.send(column.name) %></td>
<% end %>
<td><%= link_to 'assign', :action => 'assign', :id => calendar %></
</tr>
<% end %>
The calendar-entry has a column called project_has_person_id, but
whenever i try to access the parameter in the controller with
params[:project_has_person_id] the value will be nil.
i am new to ruby on rails, and this might be a simple one but i have
no idea what to do.
i need to put a select (_tag or whatever) into a list.rhtml and get
the selected value from this. Putting the select to the view works
fine. The displayed options are ok too, but i don't know how to get
the selected option. What i have so far:
<% for column in Calendar.content_columns %>
<td><%=h calendar.send(column.name) %></td>
<% end %>
<td><%= link_to 'assign', :action => 'assign', :id => calendar %></
>
</tr>
<% end %>
The calendar-entry has a column called project_has_person_id, but
whenever i try to access the parameter in the controller with
params[:project_has_person_id] the value will be nil.
I suspect that the value is in params[:calendar][:project_has_person_id].
The development log will show you all of the values of the params object.
i am new to ruby on rails, and this might be a simple one but i have
no idea what to do.
i need to put a select (_tag or whatever) into a list.rhtml and get
the selected value from this. Putting the select to the view works
fine. The displayed options are ok too, but i don't know how to get
the selected option. What i have so far:
<% for column in Calendar.content_columns %>
<td><%=h calendar.send(column.name) %></td>
<% end %>
<td><%= link_to 'assign', :action => 'assign', :id => calendar %></
>
</tr>
<% end %>
The calendar-entry has a column called project_has_person_id, but
whenever i try to access the parameter in the controller with
params[:project_has_person_id] the value will be nil.
thank you for your reply.
i have tried your solution, but it didn't work either.
is there really no way to pass a selected value coming from a
selection to a controller?
Try to place your select statement inside a form tag instead of
link_to, only then it submits the selection to the controller.
Then you need to access the selection by params[:calendar]
[:project_has_person_id] as stated by Christopher.