The MEAN Stack for Rubyists

I’ve been hearing about the MEAN stack for a long time now.  I heard what it stands for:  Mongodb, Express.js, Angular, and Node.  I also heard that it was roughly analogous to the LAMP stack (Linux, Apache, MySQL, and PHP).

Even after learning JavaScript and Angular, and using Mongodb a few times, I still didn’t quite understand the MEAN stack.  But this morning I read this excellent article that laid it out in a way I understood instantly.

Mongodb is the database

Express.js is a framework like  Sinatra

Angular is the templating framework (like erb)

Node is the server

NPM is like Bundler.

Easy enough!

Brakeman and Rails Security

I had the chance to listen to this talk today:

It’s very good.  On my way home from work, I listened to a Ruby Rogues podcast on Brakeman.  So, naturally when I got home I installed Brakeman and ran it on my reporting app.

I’m happy to report that the only vulnerabilities reported were due to the version of rails I used, and not my code.  But then, after watching the video, I wonder what that’s worth?

Random Quote Generator

Today I created this random quote generator.  It’s very basic, but it was a fun project.

It’s been a while since I posted!  I’ve been working on my rails app for work.  I attended Knoxville’s first ever RailsBridge as a volunteer – it went very well!  I’ve also been learning AngularJS.  Finally, I took on a volunteer project to get a rails app deployed.  Basically, we will be modifying this site and putting it up for the city of Knoxville.

Deployment is hard.  And working on an existing rails app is hard.  There’s a lot of gems in the app that I know nothing about.  But I’m making progress.

Concatenating arrays in JavaScript

So here’s an interesting thing I came across:

var arrays = [[1, 2, 3], [4, 5], [6]];
console.log(arrays.reduce(function(a, b){
return a + b;


I was playing around with Array.reduce and Array.concat, and started wondering what would happen if I tried to add up the total of all elements in the variable arrays.  I didn’t quite get what I was expecting.

var a = [1,2,3];
var b = [2,3,4];
console.log(a + b);

// 1,2,32,3,4

Apparently, the + operator acts to concatenate arrays. It recognizes commas, but the brackets confuse it somehow?

If anyone has a good explanation of this I’d love to hear it.

Progress May 10, 2015

This seems like a good time to post an update.

After my last post, I evaluated the rails project I had just completed, and decided I wanted to move on to something else, rather than trying to improve it.  Somehow I came across, and decided to take it on.  I have been making good progress.  The background I had from the Odin Project meant that I had a lot of the basics down already, so the first part, 200 hours of lessons, was basically just me checking “I’ve completed this” or else going to codecademy and doing a quick review.

The next section is 200 hours of practice.  I started on April 29, and I’m almost halfway through.  It has not been 100 hours, more like maybe 30.  In the meantime, I’ve noticed that you can do just about anything with if statements and for loops.

I’ve also started working through Eloquent JavaScript.  It’s well written, and covers some more advanced ideas in JavaScript.

This weekend, without a lot of time to devote to code, I started messing around whenever I had a free minute, and built a JavaScript calculator.  It’s nothing fancy, but I built it in just a few hours yesterday and today, so that makes me feel good about my progress.

Finally, I deployed my check register to heroku (even though it’s ugly and super basic), and updated my personal webpage at

Overall, I’m very happy with where I am now.  While I was working on Rails, I felt like learning was taking me forever.  But working in JavaScript has shown me that I have a grasp of some programming fundamentals.  Of course I still have a lot to learn.  But that’s the fun part!

My First Rails App Without a Tutorial

I recently created a check register app with Rails.  It’s simple, and needs some work, but I came up with the idea and created it without following any tutorial, so I’m feeling proud of myself!

I’m not going to deploy it until I get some things changed.  The code is at

I’m at an interesting point with it.  I have two different tables, one for checks and one for deposits.  I’m thinking about merging both of those into one table, called Transactions, which would have a “type” row, where I could select deposit or check.  But I’m not sure that’s the best way.  It might be better to keep the checks and deposits table separate, and link them to accounts through transactions.  I’ll be thinking about it.

I’ve also been thinking about putting my hangman game on rails, but having a little trouble conceptualizing it.  I think I will have a Game model, which will hold the random word, turns taken, letters guessed, etc – similar to the saved game in my version written in Ruby.  To save a game, instead of creating a text file using yaml, the game would just persist in the database.  The views would just be where input is taken.  But I’m not sure where the logic will go.  Still thinking about it!

I have made real progress, and feel great about creating a functional app on my own.  But I still have a long way to go, and I’m fighting that same old feeling of not knowing what to do next.  I should come up with a name for this feeling, since it’s so common.

Progress Update on the Odin Project

I’m currently working on the Event Manager project, in the Advanced Forms and Active Record section of the Odin Project.  I’m getting a little frustrated with it, as there are gaps in the material (or else I’ve just missed some things).  I feel like I’m spending  a lot of time looking things up and trying to recreate how to do things.

My plan is to do some other tutorials for a while.  The tutorials at Jumpstart Labs look great.  I’ve worked through a few of them already.  I feel like I just need some practice and  exposure to some things before I break on through to the other side.


Code Works but Tests Fail

I have been working on a Connect 4 game with a friend.  We are doing this for the Odin Project’s testing section.  The game works, but I cannot get the tests to pass.

Note:  This is solved, see the comment.

Below is an image of the board:

connect4 board

If a player drops 4 tokens in a row, that player wins:


My code is working fine, but when I run tests on the method which checks for a win, the tests fail.

The relevant tests are:


The first of these tests passes fine, because the starting value of game.won? is false.  In order to break out of the game loop, game.won? is changed to true:


But I can’t get the tests to pass for the life of me.  I’ve tried expect(game.won?).to eq(true), expect(game.won?).to be_true, expect(game.won?).to be_truthy, and still nothing works. I put the analyze_board function into its own module, and added the question at the end asking if you want to start a new game, so the game doesn’t exit immediately.  Still no luck!

The code is on my github if anyone wants to take a look.

Practicing Rails by Justin Weiss

Just two days ago I was listening to the Ruby on Rails podcast and I heard an interview with Justin Weiss.  At the time of the interview, Justin was still working on his book, Practicing Rails: Learn Rails Without Being Overwhelmed.

I had been feeling pretty overwhelmed.  I’d finished chapter 9 of the Rails Tutorial, trying to complete the roll-your-own authorization project in the Odin Project.  My problem was the sheer volume of things to remember.  I’ve completed Hartl’s tutorial up to chapter 9, read all the Odin Project suggested material, and even been through the first 7 chapters of Hartl twice, and I still felt in over my head.  It’s hard to even know where to look for answers when your subject matter is so big.  Sometimes you put your code into the model, sometimes you put it in the controller, sometimes in the view… and where did Hartl even cover this again?  Is this supposed to be a helper method?  A Rails method or something I’ll have to write myself?

Rails is big.  And complicated (although well organized!).

So that evening I checked out Justin’s blog and found that the book is out!  I downloaded the free first chapter and I was impressed enough to buy the book.

I’m happy to report that the book has been immediately helpful to me, specifically the recommendation to build lots of tiny apps to learn small pieces at a time.  Somehow, this shifted my thinking from being overwhelmed and intimidated by rails.  Suddenly, I began to see it as more of a tool that I could tinker with and learn to use, little by little.  Instead of worrying about views, layouts, testing and all that every time I try to learn a new concept, I can just work on the single concept I’m trying to figure out.

There’s a lot of good, common sense advice throughout the book on how to break learning, and other problems, down into small enough chunks that it becomes trivial.

It’s so easy to get swept into the big complex ocean of information.  Google for one small problem you’re having with your project and you can get sucked down into a world of learning about gems, strange programming techniques with funny acronyms,  and on and on.  Practicing Rails will help you cut through all that complexity.

Thanks Justin!