Module: ActiveScaffold::Helpers::ControllerHelpers

Includes:
IdHelpers
Defined in:
lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/controller_helpers.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from IdHelpers

#action_iframe_id, #action_link_id, #active_scaffold_calculations_id, #active_scaffold_column_header_id, #active_scaffold_content_id, #active_scaffold_id, #active_scaffold_messages_id, #active_scaffold_tbody_id, #active_scaffold_tools_form_columns_to_ignore, #active_scaffold_tools_list_columns, #association_subform_id, #before_header_id, #controller_id, #customize_form_id, #element_cell_id, #element_form_id, #element_messages_id, #element_row_id, #empty_message_id, #field_error_id, #id_from_controller, #loading_indicator_id, #nested_id, #search_form_id, #search_input_id, #sub_form_id, #sub_form_list_id, #table_action_id

Class Method Details

.included(controller) ⇒ Object



4
5
6
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/controller_helpers.rb', line 4

def self.included(controller)
  controller.class_eval { helper_method :params_for, :main_path_to_return }
end

Instance Method Details

#main_path_to_returnObject

Parameters to generate url to the main page (override if the ActiveScaffold is used as a component on another controllers page)



25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/controller_helpers.rb', line 25

def main_path_to_return
  parameters = params.clone
  if params[:parent_controller]
    parameters[:controller] = params[:parent_controller]
    parameters[:eid] = params[:parent_controller]
  end
  parameters[:nested] = nil
  parameters[:parent_model] = nil
  parameters[:parent_column] = nil
  parameters[:parent_id] = nil
  parameters[:action] = "index"
  parameters[:id] = nil
  params_for(parameters)
end

#params_for(options = {}) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/controller_helpers.rb', line 10

def params_for(options = {})
  # :adapter and :position are one-use rendering arguments. they should not propagate.
  # :sort, :sort_direction, and :page are arguments that stored in the session. they need not propagate.
  # and wow. no we don't want to propagate :record.
  # :commit is a special rails variable for form buttons
  blacklist = [:adapter, :position, :sort, :sort_direction, :page, :record, :commit, :_method, :authenticity_token]
  unless @params_for
    @params_for = params.clone.delete_if { |key, value| blacklist.include? key.to_sym if key }
    @params_for[:controller] = '/' + @params_for[:controller] unless @params_for[:controller].first(1) == '/' # for namespaced controllers
    @params_for.delete(:id) if @params_for[:id].nil?
  end
  @params_for.merge(options)
end