Ruby on rails 轨道选项\u从\u集合\u中为\u选择当前选择值
我有一个select表,它是使用 视图:Ruby on rails 轨道选项\u从\u集合\u中为\u选择当前选择值,ruby-on-rails,Ruby On Rails,我有一个select表,它是使用 视图: <select id = "car_type", name="car_type"> <%= options_from_collection_for_select @cartype, 'id', 'name' %> <select> 在控制器里我有这个 @cartype=cartype.find(:all) 我需要获取当前的选择值,以便根据第一个选项选择生成第二个选择表。我知道这可以用observe
<select id = "car_type", name="car_type">
<%= options_from_collection_for_select @cartype, 'id', 'name' %>
<select>
在控制器里我有这个
@cartype=cartype.find(:all)
我需要获取当前的选择值,以便根据第一个选项选择生成第二个选择表。我知道这可以用observe_字段来完成,但是,observe_字段存在一些问题,所以首先我决定使用参数传递
如有任何提示,我将不胜感激
任何人都可以指出,我如何获得当前选择值并传递该值?正如您在最后一个参数中所看到的,该参数是所选值,应该是一个整数。例如
options_from_collection_for_select(@people, 'id', 'name', 1)