Ruby on Rails Wednesday, September 4, 2019

let's say there are 2 models.

user model:

has_many :posts

post model:

belongs_to :user

has_many_attached :files, dependent: :destroy

what I want is simply all files of the user. something like:

has _may :post_files , through: posts, class_name: "XXX"

or any other way which can give me all the files of the user.

so I want all files of all posts which belong to the user. like user.post_files

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/5fbbb4cb-4694-497b-b9b8-b80628426065%40googlegroups.com.

No comments:

Post a Comment