Ideals of cubic algebras and an invariant ring of the Weyl algebra