开发者

Basic rails collection select question

开发者 https://www.devze.com 2023-02-18 09:56 出处:网络
A card can have one of many card_types. There are two models, card and card_type, where card_type is an [id, card_type_desc]开发者_如何学JAVA pairing.

A card can have one of many card_types. There are two models, card and card_type, where card_type is an [id, card_type_desc]开发者_如何学JAVA pairing.

When you define a new card, you have to pick a card-type from a drop down list.

I have the list rendering correctly with the below collection_select box, but the new card.card_type_id field is NULL. How do you set it to the value from the list?

<%= collection_select(:card_type, :id, @card_types, :id, :card_type_desc) %> 

Thanks in advance.


I am guessing, It should be...

<%= collection_select(:card, :card_type_id, @card_types, :id, :card_type_desc) %>
0

精彩评论

暂无评论...
验证码 换一张
取 消