作者dickstar (To you)
看板Ruby
標題[問題] RoR下如何使用select撈資料呢?
時間Mon Mar 8 21:23:50 2010
環境:
Ruby 1.8.7 & Rails 2.2.2
狀況:
我在想用form_helper做到一件事, 動態撈資料
例如:
class Brand < ActiveRecord::Base
has_many :PCs
end
class PC < ActiveRecord::Base
belongs_to :brand
has_many :orders
end
class Order < ActiveRecord::Base
belongs_to :PC
end
我在Order的Add View裡可以使用
<%= collection_select(:sheet, :PC_id, PC.all, :id, :name, {:include_blank => true}) %>
可是資料多的時侯就要翻好幾頁才找的到資料
請問要如何做先選擇品牌, 選完之後再選擇相關的PC呢?(感覺像是兩階段的select)
感謝大大們賜教?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 59.127.157.91
1F:→ ryudo:請參照:join 03/10 18:36