2
我使用回形針來存儲兩種不同尺寸的圖像(除了原始圖像)。這裏是類:Rails回形針 - 獲取不同尺寸圖像的路徑
class PassTemplate < ActiveRecord::Base
self.table_name = "ba_pass_templates"
belongs_to :organization
has_many :passes
has_attached_file :logo, styles: { :logo => ["29x29#", :png], :logo_2x => ["58x58#", :png] }, :dependent => :destroy
我可以抓住的文件路徑爲原來很輕鬆地:
PassTemplate.find(1).logo.path
這給了我:
"<full_system_path>/public/system/pass_templates/logos/000/000/040/original/dog_closeup.jpg"
是否有一個快速和容易訪問到抓住其他尺寸的路徑? 我可以寫我自己的,但我會認爲會有一個更簡單的方法來抓住它。
理想我想能有這樣的事情:
PassTemplate.find(1).logo.logo_path (or small_path, or whatever the path for that image was)
"<full_system_path>/public/system/pass_templates/logos/000/000/040/original/dog_closeup.jpg"
謝謝 - 僅此而已。我覺得有一些簡單的方法。 – Squadrons 2013-03-05 19:13:08