Module: Wallaby::ApplicationHelper

Defined in:
lib/helpers/wallaby/application_helper.rb

Instance Method Summary collapse

Instance Method Details

#clean_paramsObject



2
3
4
# File 'lib/helpers/wallaby/application_helper.rb', line 2

def clean_params
  params.except :resources, :action
end

#url_for(options = nil) ⇒ Object

override ‘actionview/lib/action_view/routing_url_for.rb#url_for`



7
8
9
10
11
12
# File 'lib/helpers/wallaby/application_helper.rb', line 7

def url_for(options = nil)
  if options.is_a?(Hash) && options.slice(:action, :resources).length == 2
    return wallaby_resourceful_url_for options
  end
  super
end

#wallaby_resourceful_url_for(options = {}) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/helpers/wallaby/application_helper.rb', line 14

def wallaby_resourceful_url_for(options = {})
  # DEPRECATION WARNING: You are calling a `*_path` helper with the `only_path` option explicitly set to `false`. This option will stop working on path helpers in Rails 5. Use the corresponding `*_url` helper instead.
  options = options.except :only_path
  case options[:action]
  when 'index', 'create'
    wallaby_engine.resources_path options
  when 'new'
    wallaby_engine.new_resource_path options
  when 'edit'
    wallaby_engine.edit_resource_path options
  when 'show', 'update', 'destroy'
    wallaby_engine.resource_path options
  else
    wallaby_engine.url_for options
  end
end