Ability to attach models when creating parent models. #611
adrianthedev
started this conversation in
Feature requests
Replies: 1 comment 4 replies
-
Assuming the class User < ActiveRecord::Base
has_many :user_posts
has_many :posts, through: :user_posts
end
# ... assume similar/necessary set up for `UserPost` & `Post`
class UserResource < Avo::BaseResource
field :posts, as: :has_many
field :post_ids, as: :multi_select, name: 'Posts', only_on: [:forms], options: ->(_) { Post.pluck(:title, :id) }
end |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
If you have a
User
model thathas_many
Post
s you might want to attach some posts when creating theUser
model.Right now you have to first sane the
User
and then attach the other models in theShow
screen.Beta Was this translation helpful? Give feedback.
All reactions