TL;DRI need a way to refactor a complex user dashboard with several objects and some complex data to display a accounting chart. I have read about both presenters (also called decorators or view models) and service object, but I'm not sure if I should use one or the other, or both? And how to implement this? My model and controller are pretty messy, so if anyone have some hints or suggestions, would I really appreciate it.Long version:I'm currently working on an application that helps users to coordinate dinner clubs and all  related accounting. (A dinner club is where people in a group, take turns to cook for the rest and then you pay a small amount to participate. This is pretty normal in dorms and colleges where I'm from). When you login are you presented to a dashboard with all important information separated in three blocks: the next dinner and option to registrate, the next dinner where you have to cook, and accounting overview like current debt, spendings etc.This gets pretty messy: a lot of instance variables in my controller, and a lot of methods to present this view in my models.So now to the real question: can anyone tell me any good hints, design patterns or general advice to help me refactor this code? I have read about presenters, service objects, decorators etc. but I'm not sure which to use and how.Here are some examples of how bad it looks right now (a kitchen is the group of people that have dinner together):# app/controllers/dashboard_controller.rbdef index  @user = current_user  @kitchen = @user.kitchen  @upcoming_dinner_clubs = @user.upcoming_dinner_clubs # The next dinner clubs where the current user have to cook  @users_next_dinner_club = @user.next_dinner_club # The first of upcoming_dinner_clubs  @unpriced_dinner_clubs = @user.unpriced_dinner_clubs # Old dinner clubs where the user haven't specified a price yet  # The next dinner club in the kitchen  @next_dinner_club = @kitchen.next_dinner_club if @kitchen.next_dinner_club  @todays_dinner_club = @next_dinner_club if @next_dinner_club && @next_dinner_club.date.today?endThis view shows some chart of the expenses and spendings of a user, rendered through JavaScript. My views are in HAML.# app/views/dashboard/_expenses.html.haml%h2 Dit forbrug  %p    = t '.usage_html', expenses: number_to_currency(@user.last_month_expenses), spendings: number_to_currency(@user.last_month_spendings), results: number_to_currency(@user.last_month_results)    = content_tag :div, , id: revenue_chart, class: chart dashboard-chart, data: { chart: @user.usage_chart_data }    = t '.results_html', results: number_to_currency(@user.total_results)    = content_tag :div, , id: result_chart, class: chart dashboard-chart, data: { chart: @user.result_chart_data }Don't want you to bore you with all the details, and how the methods work, but this is the methods i have, only for displaying the expenses and spendings data in the view:# app/models/user.rbdef last_month_expenses  expenses_for((1.month + 1.day).ago, 1.day.ago)enddef last_month_spendings  spendings_for((1.month + 1.day).ago, 1.day.ago)enddef last_month_results  results_for((1.month + 1.day).ago, 1.day.ago)enddef spendings_for(start_date, end_date, kitchen)enddef expenses_for(start_date, end_date, kitchen)enddef fee_for(start_date, end_date, kitchen)enddef accounting_query_conditions(start_date, end_date, kitchen)  {date: start_date..end_date, kitchen_id: kitchen.id}enddef results_for(start_date, end_date)  spendings_for(start_date, end_date) - expenses_for(start_date, end_date)enddef total_fee(date = Date.today, kitchen = primary_kitchen)enddef total_spendings(date = Date.today, kitchen = primary_kitchen)enddef total_used_on_dinner_clubs(date = Date.today, kitchen = primary_kitchen)enddef total_expenses(date = Date.today, kitchen = primary_kitchen)enddef total_results(date = Date.today, kitchen = primary_kitchen)  total_expenses(date, kitchen) - total_spendings(date, kitchen)end
Complex dashboard using presenters and/or service objects
ruby;design patterns;ruby on rails;haml