Module: TheSortableTreeController::DefineVariablesMethod

Included in:
ExpandNode, Rebuild, ReversedRebuild
Defined in:
app/controllers/the_sortable_tree_controller.rb

Instance Method Summary collapse

Instance Method Details

#the_define_common_variablesObject



15
16
17
18
19
20
21
# File 'app/controllers/the_sortable_tree_controller.rb', line 15

def the_define_common_variables
  collection = self.class.to_s.split(':').last.sub(/Controller/,'').underscore.downcase                 # 'recipes'
  collection = self.respond_to?(:sortable_collection) ? self.sortable_collection : collection           # 'recipes'
  variable   = collection.singularize                                                                   # 'recipe'
  klass      = self.respond_to?(:sortable_model) ? self.sortable_model : variable.classify.constantize  #  Recipe
  ["@#{variable}", collection, klass]
end