May 28, 2015 by Daniel P. Clark

Rails’ HashWithIndifferentAccess

A Ruby Hash is a very powerful collection type to use in Ruby.  When working in Rails sometimes you’ll have symbols as keys or sometimes they will be strings.  If you use a normal Hash these will store as different keys for the same name. sample = Hash.new sample[:a] = 1 sample[“a”] = 2 sample…

Continue Reading »

May 16, 2015 by Daniel P. Clark

Switching From Unicorn to Puma on Heroku is Easy!

I’ve had my project running on Heroku with Unicorn for some time now.  Not that long ago Heroku put out a notice advising people to switch over to Puma as Unicorn doesn’t do well with low latency connections.  And you know that with the internet you’re always going to have people with slow connections accessing…

Continue Reading »

May 9, 2015 by Daniel P. Clark

Chaining an Array into Arel ors

I’d like to keep this post short.  So the basic idea behind this is that Arel helps you build SQL queries.  When you want to join multiple queries together into one result you use Arel’s or method.  The way Arel chains additional query commands is by nesting inside the current query.  For example, if you…

Continue Reading »

April 8, 2015 by Daniel P. Clark

ActiveRecord vs Me… Round 1 – FIGHT!

I’ve done a fair bit of work in creating a library that integrates with ActiveRecord Objects.  I also have a pretty good grasp on mixins/inheritance.  Yet I still run into situations where trying include, extend, and techniques for monkey patching just don’t work out. I was trying to implement a method like first_or_create on the…

Continue Reading »

February 14, 2015 by Daniel P. Clark

Use the given project generators

Rails Before I started using Rails I was the guy who would type out web projects by hand… I was accustomed to it.  I knew what I was working with all the time simply because I wrote it.  When I had started reading the docs on Rails I was trying to learn it in this…

Continue Reading »

February 6, 2015 by Daniel P. Clark

Getting Into Rails Model Queries

For the longest time I was stubborn against learning “database programming”.  It was the abhorrent syntax that made me so resistant.  But low and behold there came Rails who found it in their heart to make a middle man ActiveRecord in which to slay the evil abhorrent syntax by resolving all good details in more…

Continue Reading »

February 1, 2015 by Daniel P. Clark

Discovering UJS with AJAX

Having worked with Rails a while I’d heard of UJS as being Unobtrusive JavaScript.  I had thought that it was simply a pattern of writing your JavaScript in a JS file to be called via a method call rather than inline JavaScript within elements in the view.  So I had definitely overlooked the benefit of…

Continue Reading »

January 28, 2015 by Daniel P. Clark

Rails Helper Methods

When I had started developing in Rails it was months before I even heard of “Helper Methods”.  I did see the folder in the app directory, but I didn’t see any use for it at the time.  I mean Rails is pretty much Model-View-Controller, so why would anyone need helper methods? Well once I found…

Continue Reading »

January 16, 2015 by Daniel P. Clark

The 500 Millisecond Rails Partial

Click… 15 seconds later: “Something went wrong”.  So that happened.  I’d written a web based email client and it was taking too long to load.  If it reached 15 seconds it would quit because of the servers time-out setting.  Here’s my journey into finding out what went down. First things first, I needed to know…

Continue Reading »

Encryption in Ruby on Rails

January 9, 2015 by Daniel P. Clark

Encryption in Ruby on Rails

When I had first looked into encrypting data in my Rails database I found on a couple of forms, and StackOverflow issues, they recommended two gems: attr_encrypted and strongbox.  Besides that there where a few do it yourself examples with Ruby’s built-in OpenSSL library and some other small libraries like AESCrypt.  After examining these gems…

Continue Reading »

Page 1 of 2
1 2
1 2