read
We all know that rails models associations gets defined while class definitions are loaded and once defined can’t be changed.
But still you can make use of block parameter
to conditions to have dynamic query conditions
inside associations.
Below line explains how to define dynamic associations :
Please make a note that below code will not work :