Active Stotage - has_many attached_files ,through: Parent

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

has_many_attached :files actually sets to has_many relationships: has_many :files_attachments and has_many :files_blobs, you could use those has_many relationships to use on your user’s has_many :through relationship.

Thank you so much for your help. it works now!