I want to log the actions of the users.
I do it like this
when creating a product:
in the controller
def create @product = Product.new(params[:product])
if @product.save
if isLogging()
createLog(@product,controller) #here i need to pass the controller or
just the action
end
flash[:notice] = 'Product was successfully created.'
redirect_to :action => 'show', :id => @product
else
render :action => 'new'
end
end
in the application controller
def isLogging()
return true
end
def createLog(obj,the_controller)
log = LogFile.new()
log.the_class = obj.class
log.the_class_id = obj.id
log.the_action = the_controller.action_name
if User.backend_user != nil
log.user_name = User.backend_user.user_name
end
log.save
end
It doesnt know “controller”,
i want to use it like this