Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

remove conditions_from_params from nested links

  • Loading branch information...
commit 1dd98910cd16e1420aa35ed8ee5523d2532f8f2d 1 parent 6b8ab9c
@scambra scambra authored
View
1  CHANGELOG
@@ -7,6 +7,7 @@
- Fix searches with no results, it was loading first page without conditions
- Allow to change highlight options with ActiveScaffold.js_config
- allow to override column count calculation for colspan
+- Remove conditions_from_params from nested links
= 3.2.11
- improve support for tableless models and active_scaffold_batch
View
16 lib/active_scaffold/actions/core.rb
@@ -150,14 +150,16 @@ def beginning_of_chain
# Builds search conditions by search params for column names. This allows urls like "contacts/list?company_id=5".
def conditions_from_params
- conditions = {}
- params.reject {|key, value| [:controller, :action, :id, :page, :sort, :sort_direction].include?(key.to_sym)}.each do |key, value|
- next unless active_scaffold_config.model.columns_hash[key.to_s]
- next if active_scaffold_constraints[key.to_sym]
- next if nested? and nested.constrained_fields.include? key.to_sym
- conditions[key] = value
+ @conditions_from_params ||= begin
+ conditions = {}
+ params.reject {|key, value| [:controller, :action, :id, :page, :sort, :sort_direction].include?(key.to_sym)}.each do |key, value|
+ next unless active_scaffold_config.model.columns_hash[key.to_s]
+ next if active_scaffold_constraints[key.to_sym]
+ next if nested? and nested.constrained_fields.include? key.to_sym
+ conditions[key.to_sym] = value
+ end
+ conditions
end
- conditions
end
def new_model
View
6 lib/active_scaffold/helpers/controller_helpers.rb
@@ -2,10 +2,14 @@ module ActiveScaffold
module Helpers
module ControllerHelpers
def self.included(controller)
- controller.class_eval { helper_method :params_for, :main_path_to_return, :render_parent?, :render_parent_options, :render_parent_action, :nested_singular_association?, :build_associated}
+ controller.class_eval { helper_method :params_for, :params_conditions, :main_path_to_return, :render_parent?, :render_parent_options, :render_parent_action, :nested_singular_association?, :build_associated}
end
include ActiveScaffold::Helpers::IdHelpers
+
+ def params_conditions
+ conditions_from_params.keys
+ end
def params_for(options = {})
# :adapter and :position are one-use rendering arguments. they should not propagate.
View
11 lib/active_scaffold/helpers/view_helpers.rb
@@ -123,9 +123,11 @@ def action_link_url_options(link, url_options, record, options = {})
url_options[:controller] = link.controller.to_s if link.controller
url_options.delete(:search) if link.controller and link.controller.to_s != params[:controller]
url_options.merge! link.parameters if link.parameters
- @link_record = record
- url_options.merge! self.instance_eval(&(link.dynamic_parameters)) if link.dynamic_parameters.is_a?(Proc)
- @link_record = nil
+ if link.dynamic_parameters.is_a?(Proc)
+ @link_record = record
+ url_options.merge! self.instance_eval(&(link.dynamic_parameters))
+ @link_record = nil
+ end
url_options_for_nested_link(link.column, record, link, url_options, options) if link.nested_link?
url_options_for_sti_link(link.column, record, link, url_options, options) unless record.nil? || active_scaffold_config.sti_children.nil?
url_options[:_method] = link.method if !link.confirm? && link.inline? && link.method != :get
@@ -195,7 +197,8 @@ def url_options_for_nested_link(column, record, link, url_options, options = {})
url_options[active_scaffold_config.model.name.foreign_key.to_sym] = url_options.delete(:id)
url_options[:eid] = nil # needed for nested scaffolds open from an embedded scaffold
end
- nested.constrained_fields.each { |field| url_options.delete field } if nested?
+ url_options.except! *params_conditions
+ url_options.except! *nested.constrained_fields if nested?
end
def url_options_for_sti_link(column, record, link, url_options, options = {})
Please sign in to comment.
Something went wrong with that request. Please try again.