Module: ShouldaRouting::Routes::Helpers
- Included in:
- ShouldaRouting::Resources::Base
- Defined in:
- lib/shoulda_routing/routes/helpers.rb
Instance Method Summary collapse
- #route_params(stack, options = {}) ⇒ Object
-
#route_path(stack, options = {}) ⇒ Object
Returns a string path according to an array.
-
#route_permutations(stack) ⇒ Object
Returns the combinations according to an array passed by param.
Instance Method Details
#route_params(stack, options = {}) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/shoulda_routing/routes/helpers.rb', line 16 def route_params stack, = {} params = {} stack[0...stack.size - 1].each do |resource| params[:"#{resource.to_s.singularize}_id"] = "1" end params.merge!() params end |
#route_path(stack, options = {}) ⇒ Object
Returns a string path according to an array.
6 7 8 |
# File 'lib/shoulda_routing/routes/helpers.rb', line 6 def route_path stack, = {} "/#{stack.join("/1/")}" + [:suffix].to_s end |
#route_permutations(stack) ⇒ Object
Returns the combinations according to an array passed by param. This is in order to generate all the nested routes.
12 13 14 |
# File 'lib/shoulda_routing/routes/helpers.rb', line 12 def route_permutations stack stack.inject(&:product).map{|e| e.flatten rescue [e]} end |