Problem Solution
Category: Ruby
Processing requests using the user’s time zone
Problem I have an application in Ruby on Rails (3.2) and I want all the requests to take into account […]
Checking for rvm Ruby versions
Problem As it is going to be used as part of some automation and not just at the command line […]
Combining two Arrays of hashes based on a hash key
Problem I have two arrays of variable lengths: people1 and people2. I want to create an array of arrays where […]
Calculating change based on input
Problem I decided to make a program that calculates change, based on an input. My code is extremely long, and […]
Duplication of enum across two models
Problem In my Rails app, I have two classes each with the same enum for status. Code climate is complaining […]
ActiveRecord model for upvotes and downvotes
Problem How can I make my model DRY and KISS? class Rating < ActiveRecord::Base attr_accessible :item_type, :item_id, :rating, :voters_up, :voters_down […]
fi
Problem Solution
How could this “complex method” for codeclimate be refactored?
Problem I’m trying to figure out how to refactor some code based on what codeclimate is telling me. So far […]
Rails 6: Attaching Devise current_user.id to form submissions
Problem In my Ruby on Rails 6 app: I have a User class built with Devise, and I scaffolded a […]