Paperclip attachments with dynamic style sizes from Model

前端 未结 2 1709
迷失自我
迷失自我 2021-01-01 04:29

Using Rails 2, I try to separate different, dynamic image sizes trough another Model from the Paperclip-Model. My current approach, using a Proc, looks the following:

<
相关标签:
2条回答
  • 2021-01-01 04:42

    I'm assuming you have everything working with paperclip, such that you have uploaded an image and now the proc is just not working.

    It should work. Try not putting the size in an array.

    You are doing this

    sizes = { :thumb => ["100x100"] }
    

    But I have it where I'm not putting the size in an arry

    sizes = { :thumb => "100x100" }
    

    Give that a try :)

    0 讨论(0)
  • 2021-01-01 04:45

    The solution is simple. instance in my first example Proc is an instance of Paperclip::Attachment. As I want to call a File method, one has to get the calling instance inside the Proc:

    Proc.new { |clip| clip.instance.attachment_sizes }
    

    instance represents File-instance in the given example.

    0 讨论(0)
提交回复
热议问题