Module ScaffoldingExtensions::Model

  1. lib/scaffolding_extensions/model.rb

Instance methods shared by all models

Public instance methods

scaffold_error_messages ()

an array of strings describing problems with the object (empty if none)

[show source]
   # File lib/scaffolding_extensions/model.rb, line 4
4:   def scaffold_error_messages
5:     errors.full_messages
6:   end
scaffold_name ()

The name given to the item that is used in various places in the scaffold. For example, it is used whenever the record is displayed in a select box. Should be unique for each record, but that is not required. Should be overridden by subclasses unless they have a unique attribute named ‘name’.

[show source]
    # File lib/scaffolding_extensions/model.rb, line 12
12:   def scaffold_name
13:     scaffold_attribute_value(:name) || scaffold_id.to_s
14:   end
scaffold_name_with_id ()

scaffold_name prefixed with id, used for scaffold autocompleting

[show source]
    # File lib/scaffolding_extensions/model.rb, line 17
17:   def scaffold_name_with_id
18:     "#{scaffold_id} - #{scaffold_name}"
19:   end
scaffold_value (field)

the value of the field if not an association, or the scaffold_name of the associated object

[show source]
    # File lib/scaffolding_extensions/model.rb, line 22
22:   def scaffold_value(field)
23:     if self.class.scaffold_association(field)
24:       obj = send(field) 
25:       obj.scaffold_name if obj
26:     else
27:       send(field)
28:     end
29:   end