Problem I have an implementation for a graph node class that I’d like to have function as a directed acyclic […]
Tag: ruby-on-rails
Rails view to list users in a zebra-striped table
Problem <% i = 0 %> <% @patients.each do |patient| %> <tr class=”<%= i % 2 == 0 ? ‘Even’ […]
refactor helper for default state for rails select with enums
Problem I’ve created a helper method that is essentially used to get the default state of an select: <%= select_tag […]
Refactor or simple code RoR
Problem I have a GiftCard class where I have method can_deliver? and deliver! that I think can be refactored to […]
Bitwise operation to get the weekday name
Problem The function days_name receive a val (string) corresponding to weekdays in hexadecimal. def days_name(val) value = val.to_i(16) week = […]
Rake task to send users a reminder to post with conditions
Problem I am implementing a feature that reminds users to make a post via email if the user has set […]
Migration in a bioinformatics application that changes a column name and explains the rationale
Problem This very short piece of code is a migration in which a column name is changed to be more […]
Using model relationships to find number of responses by a user, to posts of a certain topic type
Problem I have a user, a micropost and a response model. The user has many microposts and has many responses. […]
ElasticSearch, Tire – refactor autocomplete method for multiple resources
Problem I am using ElasticSearch and Tire for search in my app across all models. I would like to refactor […]
Counting subscribers with matching ZIP code, interests, and sex
Problem I am trying to cycle through a few of these blocks. They basically narrow down a number of people […]