Module: ComboBox::ActionController::ClassMethods
- Defined in:
- lib/combo_box/action_controller.rb
Instance Method Summary collapse
-
#search_for(*args) ⇒ Object
Generates a default action which is the resource for a combo_box.
Instance Method Details
#search_for(name, model, options = {}) ⇒ Object #search_for(name, options = {}) ⇒ Object #search_for(options = {}) ⇒ Object
Generates a default action which is the resource for a combo_box. It generates an helper which takes in account selected columns for displaying. The label used to display items is based on the used columns. These columns can be used with I18n. The key used is: views.combo_boxes.<controller>.<action>
71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/combo_box/action_controller.rb', line 71 def search_for(*args) = args.delete_at(-1) if args[-1].is_a? Hash name, model = args[0], args[1] action_name = "#{__method__}#{'_'+name.to_s if name}" model = model || name || controller_name if [String, Symbol].include?(model.class) model = model.to_s.classify.constantize end return unless model.table_exists? generator = Generator::Base.new(self, action_name, model, ) class_eval(generator.controller_action, "#{__FILE__}:#{__LINE__}") # ActionView::Base.send(:class_eval, generator.view_code, "#{__FILE__}:#{__LINE__}") ComboBox::CompiledLabels.send(:class_eval, generator.item_label_code, "#{__FILE__}:#{__LINE__}") end |