Once you have fixed your code as recommended by CPallini, it's pretty easy to handle the second part, if you think about it.
You need the most repeating value, so you need to count all of the identical values - which is complicated with random order data.
But ... it you sort your data before you start counting, all the identical values will be next to each other, so counting them and working out the moist frequent becomes pretty much trivial: try it on paper with your sample data and you will see what I mean.
7, 1, 2, 3, 2, 2, 3, 4
Sorted becomes
1, 2, 2, 2, 3, 3, 4, 7
and it's easy to see that there are more '2's than any other value in a single pass though the collection - and this works regardless of how many items the collection contains.
Hint: Ruby has a sort function or two:
How to Sort Arrays & Hashes in Ruby (Examples Included)[
^]
If you are having problems getting started at all, then this may help:
How to Write Code to Solve a Problem, A Beginner's Guide[
^]