Premila Anand

Joined

1,380 Experience
13 Lessons Completed
0 Questions Solved

Activity

I was making it much harder. Good point on using byebug. I should have done that. Thank you for your help!!

Yes, that's the table I'm trying to make! I'm able to display the months, but I get stuck with the years and values. Thank you for your help!

I have an array that has nested hashes of months, years and amounts that I want to diplay in a table. My data is in this format:

[{:month=>"January", :years=>{2017=>20, 2018=>100, 2019=>300}}, {:month=>"February", :years=>{2017=>30, 2018=>40, 2019=>80}}]

I want to display it in a table that looks like this:

Month 2017 2018 2019
January
February
March...

I am a beginner and am really struggling to access the values for the invidual years.

Thanks in advance!

Posted in Forum Series Part 6: Search with Ransack Discussion

Great video! I want to download the search results into an Excel file and am able to kind of do this. I'm having 2 problems.

First, when I use the @projects variable below, it works but only allows me to download 40 results as per the will_paginate gem.

@projects = @q.result.includes(:vendor, :service_category).paginate(:page => params[:page], :per_page => 40)

Second, I have a standard download (with many tabs) that is not dependent on the search results. I want there to be two exports on the projects index page- one which is the standard spreadsheet and the other that only includes the search results. Can I do this in the index action?

This is what I have in my respond_to block

format.xls { response.headers['Content-Disposition'] = "attachment; filename=\"projects_list_created_on_#{formatted_date_today}.xls\""
and there is a corresponding index.xls.erb file in the views.

Thank you in advance for any advice!