this is mostly a theoritical question about the best practices. I’m currently programming a small browser game and it seems that most code is actual part of the User model.
That includes (hasQuest, deleteQuest, isLeader, getAlliance, sendMessage) and some more.
I’m thinking that maybe the User model code gets a bit overbloated.
The problem is that using this functions in User is more natural. For instance, hasQuest is like current_user.hasQuest in the actual code, when invoked by the User model as an instance method. On the other hand, if invoked as a class method of TavernQuest, it would be TavernQuest.getQuest(current_user), which feels syntactically worse to me.
What do you think ? Is my way correct, or i should abandon using too much code in User model ?
Code in your Model is a good thing (as opposed to your controller)… One thing to reduce model bloat is to have Modules that you include.
/lib/user_modules/gameable.rb
In addition to reducing the size of your user.rb, it will promote code re-usability.