# David Field

Joined

340 Experience
2 Lessons Completed
0 Questions Solved

## Activity

#### Posted in Ruby question - Generating a nested hash with group_by

Thank you for this Chris, it has given me a way to rethink my approach. I will try it out. I may be back, but thank you very much.

#### Posted in Ruby question - Generating a nested hash with group_by

Thanks Chris. I was thinking I might need a nested hash because I will need to look up a specific month of a specific year and then delete the value.

hash = {
2017: {month: 1, value: 4583.33}, {month: 2, value: 4583.33}, {month: 3, value: 4583.33},{month: 4, value: 4583.33}, ... },
2018: {month: 1, value: 4583.33}, {month: 2, value: 4583.33}, {month: 3, value: 4583.33},{month: 4, value: 4583.33}, ... },
2019: {month: 1, value: 4583.33}, {month: 2, value: 4583.33}, {month: 3, value: 4583.33},{month: 4, value: 4583.33}, ... },
2020: {month: 1, value: 4583.33}, {month: 2, value: 4583.33}, {month: 3, value: 4583.33},{month: 4, value: 4583.33}, ... }
}

Like I mentioned, I don't even know if the nested hash is needed, but I need to identify specific months to remove them from the further calculation.

Thank you again in advance for any help to put me in a stronger direction.

#### Posted in Ruby question - Generating a nested hash with group_by

I'm trying to create a nested hash. I have a hash with the year as the key and an amount for that year. hash = {2017 => 55000, 2018 =>55500, 2019 => 60000}

I need to divide the amount for each year by 12 to create a nested has sorted by year and then the month and monthly amount. Once I have this larger hash I will need to go through the hash and delete certain month/amount pairs for each year.

Any recommendations on how best to approach this? I iterated over the key value to create the initial hash (to divide the month values by 12) and then used the group_by feature to create the nested hash, but the hash is too nested (an extra level deep) and I cannot sort out how to get this corrected.

I can be more specific, but wanted to seek out if there were better ways to approach this problem than what I've come up with. I have found tutorials I find on using group_by somewhat limiting. Any help or guidance is greatly appreciated. Thank you in advance.

#### Posted in Store a hash in a database

Thank you for pointing me in this new direction.

#### Posted in Store a hash in a database

I have a calculator that takes yearly pension contributions into a hash. Therefore, everyone has a contribution lined up with a year. I don't want a database of dozens of years as one individuals contributions my start in 1970 while another's in 2000. I basically just want to keep the data stored in the hash it currently is in (I currently don't store this information in a database). Is hstore the best thing to look at or serialize or something else? Thank you in advance for all input.

#### Posted in Two Factor Authentication With Devise Discussion

I'm about 13 minutes into this tutorial and get a routing error.

No route matches {:action=>"show", :controller=>"two_factor"}, missing required keys: [:id]

I've checked and double checked my typing, but I often have routing errors.

Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8