0
以下兩段代碼,options_from_collection_for_select
適用於設置:selected
當我使用設置值,但是當我使用@posts.user_id
它失敗。options_from_collection_for_select不允許通過變量選擇
這是爲什麼這個工作?
select_tag "user-dropdown", options_from_collection_for_select(@users, 'id', 'fname', **11**), :class =>'form-control'
但這不是嗎?
select_tag "user-dropdown", options_from_collection_for_select(@users, 'id', 'fname', **@posts.user_id**), :class =>'form-control'
你想一個表格內實施? –