We use generating functions over group rings to count polynomials over finite fields with the first few coefficients prescribed and a factorization pattern prescribed. In particular, we obtain different exact formulas for the number of monic $n$-smooth polynomial of degree $m$ over a finite field, as well as the number of monic $n$-smooth polynomial of degree $m$ with the prescribed trace coefficient.