Post Model
class Post < ApplicationRecord
has_many_attached :images
end
控制器
params.require(:post).permit(:title, :body, images: [])
谁来解释一下....
在Index中,您可以通过:
获取第一张图像@posts.each do |post|
first_image = post.images.first # do something with it.
end