Method: CustomTable::ApplicationHelper#custom_table_fields_definition_for
- Defined in:
- app/helpers/custom_table/application_helper.rb
#custom_table_fields_definition_for(model, variant = nil) ⇒ Object
Base definition for model
326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 |
# File 'app/helpers/custom_table/application_helper.rb', line 326 def custom_table_fields_definition_for(model, variant = nil) helper_name = "#{model.model_name.singular}_custom_table_fields" if (! self.class.method_defined?(helper_name)) helper_name = "#{model.model_name.element}_custom_table_fields" # Removing namespace from model if (! self.class.method_defined?(helper_name)) raise "#{helper_name} helper is not defined so we do not know how to render custom_table for #{model}" end end if variant.nil? || method(helper_name).parameters.empty? defs = self.send("#{helper_name}") else defs = self.send("#{helper_name}", variant) end return defs.each{|x,y| y[:label] = model.human_attribute_name(x) if y[:label].nil? } end |