Module: MongoidSortableTreeController::DefineVariablesMethod

Included in:
CRUD
Defined in:
app/controllers/mongoid_sortable_tree_controller.rb

Overview

include MongoidSortableTreeController::CRUD

Instance Method Summary collapse

Instance Method Details

#the_define_common_variablesObject



6
7
8
9
10
11
12
# File 'app/controllers/mongoid_sortable_tree_controller.rb', line 6

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