A generalized version for the Rastall theory is proposed showing the agreement with the cosmic accelerating expansion. In this regard, a coupling between geometry and the pressureless matter fields is derived which may play the role of dark energy, responsible for the current accelerating expansion phase. Moreover, our study also shows that the radiation field may not be coupled to the geometry in a non-minimal way which represents that the ordinary energy-momentum conservation law is respected by the radiation source. It is also shown that the primary inflationary era may be justified by the ability of the geometry to couple to the energy-momentum source in an empty flat FRW universe. In fact, this ability is independent of the existence o...