grouped-collection-select

How to use :selected with grouped_collection_select

允我心安 提交于 2019-12-19 08:52:13
问题 Is it possible to somehow use the :selected option that you'd use on a normal select view helper with the grouped_collection_select function? I'd like to set the value that gets pre-selected in my list. I've tried passing in :selected as an option with no luck! Here's some code snippts of my tests: grouped_collection_select 'user[subscription_attributes]', :subscription_plan_id, Trade.order(:name).all, :subscription_plans, :name, :id, :display_name, { :include_blank => true, :selected => 5 }

Grouped Collection Select Alphabetical Order Rails

六月ゝ 毕业季﹏ 提交于 2019-11-29 22:27:13
问题 I finally figured out how to implement Dynamic Select menus using this tutorial. Everything works, But how does one organize the Cities in the Dropdown by Name.... Below is all of the code I've written. (Please let me know if you need any further information) New to rails please help :) VIEWS <%= simple_form_for ([@book, @rating]) do |f| %> <div class="field"> <%= f.collection_select :state_id, State.order(:name), :id, :name, {:include_blank=> "Select a State"}, {:class=>'dropdown'} %> </div>