EDITED:
I trying to refactore this:
self.before_create do |obj|
obj.position = self.class.count
end
to this:
self.before_create :set_position
private
def set_position
obj.position = self.class.count
end
But, Its displaying Error:
undefined local variable or method `obj'
How fix this?
The
set_positionmethod is instance method, soselfis assigned to the instance. ThecountI believe should be a class variable.