-
Notifications
You must be signed in to change notification settings - Fork 52
Rails 3
chrisroberts edited this page Nov 1, 2010
·
19 revisions
Minimal integration application at: http://github.com/clyfe/rails3-dav4rack-example
NOTE. People reported that for maximum compatibility webdav is to be mounted in the root ‘/’ and run on port 80, so a subdomain is perfect in that regard. Also by using a subdomain we don’t need a DAV4Rack::Interceptor.
The easyeast way to integrate with rails is:
# monkey patch method validation to allow webdav extension verbs
# make sure to run this after rails loads, say in application.rb
class ActionDispatch::Request
HTTP_METHODS = %w(get head put post delete options lock unlock propfind proppatch mkcol delete put copy move)
HTTP_METHOD_LOOKUP = HTTP_METHODS.inject({}) { |h, m| h[m] = h[m.upcase] = m.to_sym; h }
end
# mount handlers from within routs.rb just like you do with any rack app
# make sure this is above "root :to => ..." if you use constraint to subdomain,
# if not, you should mount " :at => '/somepath' "
mount DAV4Rack::Handler.new(
:root => Rails.root.to_s,
:root_uri_path => '/',
:resource_class => ::DAV4Rack::FileResource
), :at => '/', :constraints => {:subdomain => "webdav"}