Reputation: 4780
My application is a refineryCMS which is been hosted on the heroku server . I need to store the images on the postgres DB store. I got one gem dragonfly-activerecord , but not able to keep it on database . I tried:
Configure Dragonfly itself (in config/initializers/dragonfly.rb
, typically):
require 'dragonfly-activerecord/store'
Dragonfly.app.configure do
# ... your existing configuration here
datastore Dragonfly::ActiveRecord::Store.new
We need to integrate this gem into refineryCMS.. If we can store images in database for cms that will be great help for host like heroku.
Upvotes: 0
Views: 418
Reputation: 91
Awesome! Could you write this solution as a guide in Refinery CMS repository? https://github.com/refinery/refinerycms/tree/master/doc/guides
Upvotes: 0
Reputation: 4780
Here is a solution along with the dragonfly-activerecord fork . Just go to config/initializers/refinery/images.rb
Here is a code to do it. First follow dragonfly-activerecord fork steps
In Gemfile:
gem 'dragonfly-activerecord' , git: "git://github.com/arpit-clarion/dragonfly-activerecord.git"
and
bundle
rails generate migration add_dragonfly_storage
In the migration file add this code
require 'dragonfly-activerecord/migration'
class AddDragonflyStorage < ActiveRecord::Migration
include Dragonfly::ActiveRecord::Migration
end
Run rake db:migrate
and add this code:
config/initializers/refinery/images.rb
# encoding: utf-8
require 'dragonfly-activerecord/store'
Refinery::Images.configure do |config|
#...... Your configuration ....
config.custom_backend_class = 'Dragonfly::ActiveRecord::Store'
config.custom_backend_opts = {}
#...... Your configuration ....
end
This will change the whole system folder structure set into database. No need to any buckets .
Keep in mind that this system is for those applications which has less images to store as it generates big chunks in db and it converts images on request time.
Upvotes: 0
Reputation: 91
Why don't you just use Amazon S3 to store images? It works great with Heroku : http://www.refinerycms.com/guides/heroku
Upvotes: 0