Module: Formize::ActionController::ClassMethods
- Defined in:
- lib/formize/action_controller.rb
Instance Method Summary collapse
-
#search_for(*args) ⇒ Object
Generates a default action which is the resource for a unroll 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 unroll 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.unroll.<controller>.<action>
96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/formize/action_controller.rb', line 96 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__}") Formize::CompiledLabels.send(:class_eval, generator.item_label_code, "#{__FILE__}:#{__LINE__}") end |