Module: ComboBox::ActionController::ClassMethods
- Defined in:
- lib/combo_box/action_controller.rb
Instance Method Summary (collapse)
-
- (Object) search_for(*args)
Generates a default action which is the resource for a combo_box.
Instance Method Details
- (Object) search_for(options = {}) - (Object) search_for(name, options = {}) - (Object) search_for(name, model, options = {})
Generates a default action which is the resource for a combo_box. It generates an helper which takes in account selected columns for displaying. Defines a controller method search_for which searches for records corresponding to the
resource controller name. +OrdersController#search_for+ searches for orders.
@macro options
Defines a controller method search_for_NAME which searches for records
of the class +NAME+.
@param [Symbol] name
Name of the datasource. This name is used to find the model name
@macro options
Defines a controller method search_for_NAME which searches for records
of the class +MODEL+.
@param [Symbol] name Name of the datasource
@param [String, Symbol] name Name of the model to use for searching
@macro options
69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/combo_box/action_controller.rb', line 69 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 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__}") end |