Where to put logic dealing with more than one models -
In a MVC framework like Rail, business logic is required in the overall consensus model. However, when it comes to logic as "all the problems solving user", I'm not sure which model class I should argue because it needs to first look at all the solutions submitted by all users, And the problem is to gather the ID from each solution, then the problem IDs all need problems.
It looks more beautiful to put in the user model, so we can make some calls like What's more, because logic mainly deals with problem and solution models, it stinks feature jealousy to put in the user model. To avoid the feature jealousy , it seems equally well to put into problem or solution. Intuitively, I will make it like the problem in the So where should I put that argument? I can see that the relationship between I will return examples of this update April 23 2014, 07:00 UTC Note that in your case, depending on the M2M class, For example, in your case, user.getAllProblemsSolved (). However, user frequency needs us all the User ID In those places where a user instance is not easily available, we have to make one to call our
getAllProblemsSolved method.
Problem.getAllProblemsSolvedBy (userId) , but I do not have good justification for it.
problem and
is an M2M relation, so if you want to abide by the rules and put business logic in the model class, you can put
getAllProblemsSolvedby in the model code, which is M2M Represents the relationship, but using that logic, the
getAllProblemsSolved By problem ID will return, and then you
problem model class Problems must achieve.
problem class
solution , exis those two models
users and < The strength of the code> problem , so that you can query both models of this model, and so if there was an M2M model in my code, then I would give it two inquiries of both ends of the M2M relationship Gym for Responsibility.
getAllProblemsSolved By can be implemented in the
Solution model class and this
problem Can return a list of frequencies and this will be
user .
Nice information. I was searching for the same.
ReplyDeletePackers and Movers in Surat
Movers and Packers in Vadodara