I’m trying to make a function that takes 2 arguments from the user_controller and does a few queries and calculations and return the result in an array. Is this something I should set up in a helper file? And how would I return the results (I’m very new to this).
Thanks for all and any help 🙂
Unless those calculations are entirely related to your templates (html, js) you should NEVER put that stuff in helpers of any kind. It will make your app hard to test.
Your options:
1) Create a model without ActiveRecord (MyCalculations.rb in ˜/models or ~/lib)
2) Create an extension and include in existing models
Examples (sample code, not realistic)
calculator.rb in ~/models
Extensions:
~/lib/models/import/csv_ext.rb
Then, add it to your models: