ペーパークリップを使用して、1 つのデータベースを共有する 2 つのレール アプリに写真をアップロードしています。問題は、たとえば app-a で写真をアップロードすると、paperclip から次のような URL が返されることです。
アイテムモデルで設定したものは次のとおりです。
class Item < ActiveRecord::Base
attr_accessible :photo, :photo_url, :poll_id, :brand, :number_of_votes
has_attached_file :photo,
:styles => { :thumbnail => "100x100#",
:small => "150x150>",
:medium => "250x250>",
:large => "400x400>" },
:storage => :s3,
:s3_credentials => S3_CREDENTIALS,
:url=>"/item_:id/created_at_:created_at/:style.jpg"
Paperclip.interpolates :created_at do |attachment, style|
attachment.instance.created_at
end
end
他のアプリ app-b で、item.photo.url(:large) で URL をクエリすると、次のようになりました。
したがって、間違ったURLを取得しました。
ペーパークリップを設定することでそれを行う方法はありますか? ありがとう!