Block on cart, equation of motion

Consider a rigid block of $b \times h$ having mass $m$ on cart (as depicted below). The cart is given an acceleration $a$, this leads to overturning of the block. The angle of rotation is indicated by $\theta$.

This is how far I got (not considering the movement of the cart): The Lagrangian $L=T-V$ is calculated using $$T = \frac12 J \dot{\theta}^2$$ $$V = m g \Delta_y = m g \bigg(r \cos(\alpha - \theta) - \frac{h}{2}\bigg)$$ so that $$\frac{\mathrm{d}}{\mathrm{d} t} \bigg( \frac{\mathrm{d} L}{\mathrm{d} \dot{\theta}} \bigg) - \frac{\mathrm{d} L}{\mathrm{d} \theta} = 0$$ yields the EOM $$J\ddot{\theta} + m g r \sin(\alpha-\theta) = 0$$ Now, my question is: how do I add the acceleration of the cart to the RHS? My initial guess would be $$J\ddot{\theta} + m g r \sin(\alpha-\theta) = m a r \cos(\alpha - \theta)$$ where $ma$ is the force and $r \cos(\alpha - \theta)$ the lever arm. But I don't believe this is true since the block does not experience the acceleration $a$ over its full body. Can anyone help or provide some literature? Thanks.

Also, taking into account the "rocking" effect requires the piece-wise description: $$J\ddot{\theta} + \bigg\lbrace\begin{matrix} -m g r \sin(\alpha + \theta) & \theta < 0 \\ m g r \sin(\alpha - \theta) & \theta \geq 0 \end{matrix} = m a r \cos(\alpha - \theta)$$