至于回形针更改保存路径?

时间:2017-10-12 06:17:25

标签: ruby-on-rails ruby paperclip

我有一块巨石 Monolith包含两个应用程序app1app2 该文件保存在app1中,但在(@ticket.document.url)中显示app2

@ticket.document.url(在app2中)将显示路径app2_root/public/system/path/to/file,但该文件位于app1_root/public/system/path/to/file

如何更改默认设置的保存路径?

1 个答案:

答案 0 :(得分:1)

I would implement an API, if you need programatically calculated data from another app.

I would probably go ahead and do something like this in app 1:

class TicketsController < ApplicationController
  def show
    respond_to do |format|
      format.json { render json: {ticket: {document_url: @ticket.documment.url}} }
      format.html
    end
  end
end

Then in app 2:

json_string = open("https://www.app1.com/tickets/1.json") { |io| io.read }
json = JSON.parse(json_string)
document_url = json.fetch("ticket").fetch("document_url")