February 4, 2015 by Daniel P. Clark

Using Ruby Object Type Classes to Safely Build Data

When building collections of data you will find situations where the types aren’t what you planned to work with.  And when I say types I’m speaking generically of arrays, hashes, strings, integers, nil, etc.  Everything’s cosy when you know what your getting.  For example putting 10 integers into an Array: arr = [] 10.times do…

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 27, 2015 by Daniel P. Clark

or

Truthiness Both or and || will return the first item that evaluates as true from the left side to the right. true or “this doesn’t return” # => true true || “this doesn’t return” # => true false || true # => true false || false # => false false or false or 1 or…

Continue Reading »

January 20, 2015 by Daniel P. Clark

Refinements over Monkey-patching

Monkey patching is rather straight forward.  You take an existing object and you apply your own duct tape, glue, nuts and bolts, or even chewing gum.  Or if it’s bad you hit it with a hammer.  No, but more seriously, it’s when you modify something existing from outside it’s original project code. For example you…

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 »

January 1, 2015 by Daniel P. Clark

When to use Ampersand and/or Colon with Proc, Map, and Inject

So with Ruby permitting Procs called on Objects I’ve found sometimes a Colon Method will work, and sometimes you need a Ampersand Colon Method.  For example, when I map &:upcase on a list of strings it works. [“a”,”b”,”c”].map(&:upcase) # = > [“A”, “B”, “C”] But if I try without the Ampersand I get: [“a”,”b”,”c”].map(:upcase) #…

Continue Reading »

December 27, 2014 by Daniel P. Clark

“Assume Everything Will Break” Development

In Ruby, and Ruby on Rails, the community is very big on Test Driven Development (TDD). This is good! And it’s especially important when working with a team. But what patterns will you develop in buidling a huge Rails application on your own without tests? Well I’d like to call it “Assume Everything Will Break…

Continue Reading »

December 9, 2014 by Daniel P. Clark

Ruby & Ruby on Rails Methods for Discovery Part 1

When I program I see it as both an art and a challenge.  The art is in the how.  The challenges I see as detective work.  The answer is unknown as of yet, and it’s your job to sleuth it out.  A detective hunts down the clues until an answer is found.  Yes, that is…

Continue Reading »

August 4, 2014 by Daniel P. Clark

Create a Game Instance in Rails

So you need to load a class instance in Rails for your visitors to play your game. But Rails generally is a static website with static database lookups. So for this we’re going to assign a class instance to a game room. First let’s generate our project; we’re going to start with a prebuilt devise/bootstrap…

Continue Reading »

Page 4 of 5
1 2 3 4 5
1 2 3 4 5