You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
module Stock
class CategoriesController < ApplicationController
include ::TheSortableTreeController::Rebuild
class Stock::Category < ActiveRecord::Base
acts_as_nested_set
include ::TheSortableTree::Scopes
This method form gem won't work
module DefineVariablesMethod
public
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
end
If I have namespaced controller and model
This method form gem won't work
Because this line
collection = self.class.to_s.split(':').last.sub(/Controller/,'').underscore.downcase
Will result "categories"
And here
klass = self.respond_to?(:sortable_model) ? self.sortable_model : variable.classify.constantize
you will get error
*** NameError Exception: uninitialized constant Category
Because the class is not Category but Stock::Category
The text was updated successfully, but these errors were encountered: