Class: ActionDispatch::Routing::Mapper

Inherits:
Object
  • Object
show all
Defined in:
lib/webnames/rails/routes.rb

Instance Method Summary collapse

Instance Method Details

#webnames_for(resources_name, *args, &block) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/webnames/rails/routes.rb', line 3

def webnames_for(resources_name, *args, &block)
  options = args.extract_options!

  options.reverse_merge! param: :webname

  options_with_blank_path = options.reverse_merge path: '', except: [:new, :create, :index]
  options_with_path = options.reverse_merge except: [:show, :edit, :update, :destroy]

  constraints webname: Webnames.regex do
    resources resources_name, options_with_blank_path, &block
    resources resources_name, options_with_path, &block
  end
end