Module: Scrapbook::Routing

Defined in:
lib/scrapbook/routing.rb

Overview

This is a helper method for making it easier to add scrapbooks to routes.

Instance Method Summary collapse

Instance Method Details

#scrapbook(name, at: "/#{name}", folder_root: name) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/scrapbook/routing.rb', line 6

def scrapbook(name, at: "/#{name}", folder_root: name)
  folder_root = Pathname.new(folder_root)
  folder_root = Rails.root.join(folder_root) if folder_root.relative?

  Engine.config.scrapbook.paths[name] = folder_root
  mount Engine => at, defaults: {'.book': name}, as: "#{name}_scrapbook"
end