这是我upload.rb轨回形针上传自定义URL路径
class Upload < ActiveRecord::Base
belongs_to :post
has_attached_file :upload,styles: { medium: ["500x400>",:jpg], thumb: ["100x100>",:jpg]},url: "/post_images/post_:postid/:style/:filename"
def postid
self.post_id
end
end
我有POST_ID列。由于belongs_to
代表我将为一个帖子拥有多个图片。但同时保存文件夹而不是post_25
。它存储为post_:postid
但是,如果我给:id
它正在工作。
我该如何解决它。有人能帮忙吗。
s现在尝试其post_id:post_id不是post_id的值 – overflow
请参阅我的解决方案更新。 – zeantsoi