I use for loading files gem dragonfly
I have model Photo:
class Photo < ApplicationRecord
dragonfly_accessor :avatar do
default 'public/avatar.png'
end
................................
end
When i call pry(#<#<Class:0x007f83508fb8f0>>)> @photo.avatar.url
I get
=> "/media/W1siZmYiLCJwdWJsaWMvYXZhdGFyLnBuZyJdXQ/avatar.png?sha=338938a0ea07d56b"
Setting file dragonfly.
dragonfly.rb
require 'dragonfly'
# Configure
Dragonfly.app.configure do
plugin :imagemagick
secret "7c510e8ed95f9929f09981ef5f42ffc75034703184575044d2835ebbbd2a350b"
url_format "/media/:job/:name"
datastore :file,
root_path: Rails.root.join('public/system/dragonfly', Rails.env),
server_root: Rails.root.join('public')
end
# Logger
Dragonfly.logger = Rails.logger
# Mount as middleware
Rails.application.middleware.use Dragonfly::Middleware
# Add model functionality
if defined?(ActiveRecord::Base)
ActiveRecord::Base.extend Dragonfly::Model
ActiveRecord::Base.extend Dragonfly::Model::Validations
end
I need path image for paste in image_tag. How can I get correct path .../public/avatar.png?