开发者

Handling forms with class table inheritance models

I would like to use form_for except I have class table inheritance models using the citier gem. They are defined as such:

class Fruit < ActiveRecord::Base
    # calories:integer
    # c开发者_JAVA百科olor:string
end 

class Apple < Fruit
    # is_sauce:boolean
end

class Banana < Fruit
    # is_peeled:boolean
end

The problem is that I want the first part of my form to fill out attributes for my Fruit model. Then depending on a select field on what type of fruit (Apple, Banana), I then want to fill out attributes for that particular model yet I still want validations with the form_for helper. Any suggestions on how I can approach this... or additional clarification? Thanks.


What I ended up doing was asking for the model before creating the form. Then using many partials.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜