Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>First, convention has nothing to do per se with performance. </p> <blockquote> <p>Maximum part of the business logic are moved to helper.</p> </blockquote> <p>I would say this is very bad. One of the popular idioms is "fat models, skinny controllers", which works most of the time. Put all the business logic you can in your models, where they belong. If you have really complicated views you want to simplify, use decorators (e.g the draper gem), and then separate business logic (model) and view logic (decorators) into their according locations.</p> <blockquote> <p>Included all helper files in a module under lib directory and included that module in application controller.</p> </blockquote> <p>Okay I think. As long as you have one place to maintain that chain, it feels okay. If it leads to misunderstandings/misusings/hacking around, then: not okay.</p> <blockquote> <p>In many methods, no argument passed, instead they used the instance variable</p> </blockquote> <p>If you're talking about methods in your model: this is good, since the method is targeted at the scope of your instance, and not of your class.</p> <blockquote> <p>Each action will call a helper method to execute business logic and that method will call some other helper methods.</p> </blockquote> <p>Sounds strange. The controller is responsible for preparing your data used in the view. If you are preparing specific data in your helpers to assign them to your view for usage, consider putting these into a decorator (as mentioned above). But calling a helper in almost every action sounds like something is done the wrong way.</p> <blockquote> <p>All method are written as public, No protected and private method. </p> </blockquote> <p>Non-public methods should not be public. Take a look at <code>helper_method</code> and <code>hide_action</code> from ActionController.</p> <blockquote> <p>Models are used only for validation.</p> </blockquote> <p>Wrong. Models contain the business logic, as mentioned above. What about modifying things in the console? Would you want to update all logical related data by hand, then? Do you do this "by hand" in your controller right now (which it seems like) ? What about when you introduce an API, do you copy-paste the code in there to not miss some logic? And what when the logic changes, are you really sure all required endpoints manually and independently handling that logic are also updated? </p> <p>There's a reason models have relations, callbacks and instance methods. Use them! </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload