Module: ActiveScaffold::Helpers::AssociationHelpers
- Included in:
- ViewHelpers
- Defined in:
- lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/association_helpers.rb
Instance Method Summary collapse
- #association_options_count(association, conditions = nil) ⇒ Object
-
#association_options_find(association, conditions = nil) ⇒ Object
Provides a way to honor the :conditions on an association while searching the association’s klass.
-
#options_for_association(association, include_all = false) ⇒ Object
returns options for the given association as a collection of [id, label] pairs intended for the
options_for_select
helper. -
#options_for_association_conditions(association) ⇒ Object
A useful override for customizing the records present in an association dropdown.
- #options_for_association_count(association) ⇒ Object
Instance Method Details
#association_options_count(association, conditions = nil) ⇒ Object
9 10 11 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/association_helpers.rb', line 9 def (association, conditions = nil) association.klass.count(:all, :conditions => controller.send(:merge_conditions, conditions, association.[:conditions])) end |
#association_options_find(association, conditions = nil) ⇒ Object
Provides a way to honor the :conditions on an association while searching the association’s klass
5 6 7 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/association_helpers.rb', line 5 def (association, conditions = nil) association.klass.find(:all, :conditions => controller.send(:merge_conditions, conditions, association.[:conditions])) end |
#options_for_association(association, include_all = false) ⇒ Object
returns options for the given association as a collection of [id, label] pairs intended for the options_for_select
helper.
14 15 16 17 18 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/association_helpers.rb', line 14 def (association, include_all = false) available_records = (association, include_all ? nil : (association)) available_records ||= [] available_records.sort{|a,b| a.to_label <=> b.to_label}.collect { |model| [ model.to_label, model.id ] } end |
#options_for_association_conditions(association) ⇒ Object
A useful override for customizing the records present in an association dropdown. Should work in both the subform and form_ui=>:select modes. Check association.name to specialize the conditions per-column.
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/association_helpers.rb', line 27 def (association) return nil if association.[:through] case association.macro when :has_one, :has_many # Find only orphaned objects "#{association.primary_key_name} IS NULL" when :belongs_to, :has_and_belongs_to_many # Find all nil end end |
#options_for_association_count(association) ⇒ Object
20 21 22 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/association_helpers.rb', line 20 def (association) (association, (association)) end |