Fixed the issue by injecting a user in session maintained by cancan