Category Archives: Software
Deduping join data in ruby based on multiple attributes
In the past I created an app using Rails built in HABTM and no unique index on the join tables. I’m more into the has_many :through choice today.
In order to migrate my data with a unqiue index, I had a bunch of de-duping to do. It was a bit trickier than [...]
Posted in Software Tagged de-duplication, habtm, removing duplicates, ruby, Ruby On Rails, unique index Comments closed
More cool stuff with ruby’s tap method
I had to write up a quick data processor at work today and I wanted a decent output at the end of execution. The ruby tap method came in handy here.
class AssetDeliveryPopulater
def self.populate
results_text = []
asset_secrets_count, asset_delivery_count, asset_not_found_count, asset_delivery_creation_errors = 0,0,0,0
Email.all.tap{|emails| [...]
Tap before you squash
Tap is a pretty awesome ruby method I recently discovered.
Let’s say I have the following request:
post '/api/v1/users/',
params.merge(:sig =>
Authentication.calculate(TestAuthData.secret_access_key,params.to_query)
).to_json
I realize [...]
RSpec 2, Sinatra and Mongoid example
I spent yesterday coding a very abbreviated version of an authentication service that uses Sinatra, Mongoid and RSpec 2. It took more than a couple hours because there are so many outdated code samples on the web that just don’t work. I put my code up on github for people to see. [...]
Country Seed Data for your Rails App
Never go looking for basic country seed data again:
[
{ :name => 'Afghanistan', :iso_two_letter_code => 'AF' },
{ :name => 'Aland Islands', :iso_two_letter_code => 'AX' },
{ :name => 'Albania', :iso_two_letter_code => 'AL' },
{ :name => 'Algeria', :iso_two_letter_code => 'DZ' },
{ :name => 'American Samoa', :iso_two_letter_code => 'AS' [...]
Simple Quarter Select – Rails plugin for Q1,Q2,Q3,Q4 selector
Have you ever wanted a select component for Quaters of the Fiscal Year (Q1,Q2,Q3,Q4)? The Simple Quarter Select Ruby on Rails plugin does it for you. It’s highly configurable and maps to the month of any datetime attribute in your model.
Why map the quarter to a datetime attribute?
I think the answer is obvious but [...]
Posted in Software Tagged datetime, helpers, plugin, rubyonrails, simple-quarter-select Comments closed

Recursive custom to_json in Ruby for arrays of objects or nested objects