Class: ActionDispatch::Routing::Mapper

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

Instance Method Summary collapse

Instance Method Details

#wizard(url, controller, total_steps) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
# File 'lib/extensions/routes.rb', line 2

def wizard(url, controller, total_steps)
  match "#{url}/step:step" => "#{controller.to_s.underscore}#step", :via => :get, :as => controller.to_s.underscore.to_sym
  match "#{url}/step:step" => "#{controller.to_s.underscore}#step_submit", :via => :post, :as => controller.to_s.underscore.to_sym
  match "#{url}" => "#{controller.to_s.underscore}#default", :via => :get


  model_prefix = "#{controller.to_s.camelcase}Controller".constantize.model_name.to_s.underscore    
  total_steps.times do |idx|
    match "#{url}/step#{idx+1}" => "#{controller.to_s.underscore}#step", :via => :get, :as => "#{model_prefix}_#{idx}_steps"
  end
end