Hello!
I am using Dragonfly in rails. I have implemented it according to
this tutorial and it is working very good.
Now I want to also upload videofiles. Unfortunately I am not able to get it running. :(
I hope you guys can help me find the error:
initializers/dragonfly.rb
require 'dragonfly'
# Configure
Dragonfly.app.configure do
plugin :imagemagick
secret 'd045734b043b4383a246c5c8daf2d3e31217dc8b030f21861e4fd16c4b72d382'
url_format '/media/:job/:name'
datastore :file,
root_path: Rails.root.join('uploads/images/'),
server_root: Rails.root.join('uploads')
end
Dragonfly.app(:videos).configure do
secret 'd045734b043b4383a246c5c8daf2d3e31217dc8b030f21861e4fd16c4b72d382'
url_format "/media/:job/:name"
datastore :file,
root_path: Rails.root.join('uploads/videos/'),
server_root: Rails.root.join('uploads')
end
# Logger
Dragonfly.logger = Rails.logger
# Mount as middleware
Rails.application.middleware.use Dragonfly::Middleware
Rails.application.middleware.use Dragonfly::Middleware, :videos
# Add model functionality
if defined?(ActiveRecord::Base)
ActiveRecord::Base.extend Dragonfly::Model
ActiveRecord::Base.extend Dragonfly::Model::Validations
end
Video-Model:
class Video < ActiveRecord::Base
dragonfly_accessor :video, app: :videos, app_name: :videos do
storage_options do |video|
{ path: "videos/#{Video.video_uid}-#{video.name}.webm" }
end
end
end
Video-Controller: (extract)
@video = Video.new(video_params)
@video.save
Now when I upload a video, it correctly calles the video-controller and it is correctly saved in the database! But unfortunately the video can not be found in the desired directory (
uploads/videos/
).
What am I doing wrong?
I hope you can help me.
Best regards
Michael