Reputation: 33755
I am creating a family tree and I will create methods that calculate various relationships on-the-fly (e.g. "siblings", "spouses", etc.).
A few years ago the whole "fat model, skinny controller" paradigm took hold of the Rails community, so that has been my default position - just drop them in the User
model. But with Rails 4 pushing concerns and helpers so much, I am now wondering which is the best option.
Should I just drop them in my User
model, or put them in my DashboardHelper
(given that they will be used in the Dashboard#Index
), this is from a performance perspective.
I guess the issue is that ALL methods may not be called on EVERY Dashboard
view, but if I put them in the DashboardHelper
are all methods instantiated on every Dashboard#Action
?
Which is better from a performance perspective and why?
Upvotes: 1
Views: 37
Reputation: 7744
I've found that the overall loading time is decreased when data is sent to the view.
Create data-fetching and querying methods in the model (preferable) or the controller and pass the data TO the view.
The view expects data to be delivered to it. Otherwise when it has to fetch data itself (like queries being made from the view or helper methods that query the database or arrange some huge hash/array a certain way), then the view rendering speed naturally suffers.
Upvotes: 1