New Discussion

Notifications

You’re not receiving notifications from this thread.

How do I return an ActivateStorage blob URL in JSON

2
Rails

In our system we are sending webhook to an endpoint with serialized JSON for the object JobApplication.
The JobApplication has a resume attached using ActiveStorage. ( has_one_attached :resume)
How can I return a public URL to the resume in my JSON

class JobApplicationSerializer
  def self.exploded_json(object)
    json =object.to_json(:except => [:user_id,:created_at, :updated_at],
                         :include => [
                           :state => {:only => [:id, :name,:code]},
                           :country => {:only => [:id, :name,:code]}
                         ]
    )
    return json
  end

end
include Rails.application.routes.url_helpers

  def self.exploded_json(object)
    json =object.to_json(:except => [:user_id,:created_at, :updated_at],
                         :include => [
                           :state => {:only => [:id, :name,:code]},
                           :country => {:only => [:id, :name,:code]}
                         ]
    )
    if object.resume.attached?
      json[:resume] = {
        url: rails_blob_url(object.resume)
      }
    end
    return json
  end

I will also explain about Greatpeople me Kroger Schedule, Kroger great people.com schedule, feed kroger schedule today, krogerfeedback com schedule, Kroger employee schedule, Feed Kroger schedule.click here

Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 88,834+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.