Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polymorphic types #8

Closed
adamrobbie opened this issue Jul 21, 2014 · 2 comments
Closed

Polymorphic types #8

adamrobbie opened this issue Jul 21, 2014 · 2 comments

Comments

@adamrobbie
Copy link

Is it possible using the existing reflection mechanics in BHF to use a polymorphic relationship in the forms.

such that
User
belongs_to :capacity, polymorphic true

Admin
  has_one :user, as: :capacity

Looking for a way to create an user within the admin model context

@antpaw
Copy link
Owner

antpaw commented Jul 21, 2014

I don't really understand the reflections you are drawing, but bhf supports polymorphic types. Maybe you need a hook http://antpaw.github.io/bhf/#platform_options ?

@antpaw
Copy link
Owner

antpaw commented Jul 22, 2014

Did my advice help? http://antpaw.github.io/bhf/#overriding_bhf section "Adding view files" you might want to add a custom partial for your admin platform that has accepts_nested_attributes_for :user. Something i've done in ksk, here are the model https://github.com/antpaw/ksk/blob/master/app/models/concerns/ksk/asset.rb and the view https://github.com/antpaw/ksk/blob/master/app/views/bhf/form/has_many/_assets.haml

@antpaw antpaw closed this as completed Jul 22, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants