Posts tagged: rails

Serving a Static Home Page in Rails

2017-04-17 12:00:05 ][ Tags: hacking rails

TIL while working on this issue that if you dump a file into public/index.html then rails will just serve that up for you. A lot of tutorials out there talk about making a static pages controller, which seems like overkill (unless you have a lot of static pages .. but if thats the case why are you using Rails?)

Coursera Rails Module 3 Notes

2016-08-12 20:57:54 ][ Tags: rails mooc

I just finished the final module of this course. Overall I think it was a great course that provided a good overview of Ruby, and a thorough introduction to Rails. The next course dives into working with Databases and I am looking forward to learning more about Active Record.

Some Interesting Facts

Useful Resources

The lectures had a bunch of useful tools sprinkled throughout.

Things I love about Rails

Things I learned

General Rails Tooling

Testing with Rspec and Capybara

Once again, I cannot say how happy I am that this course dives right into all sorts of testing. Kudos to the JHU team for thinking about this important skill even in an introductory course. This module talked about doing acceptance testing with Capybara. We learned about:


The built in debugging tools in development mode in rails are just awesome. You get an IRB console inside of the browser, this is super useful for debugging purposes. The gems that are responsible for this functionality are byebug and web-console.

Deploying To Heroku

The course walked us through how to deploy an app to Heroku. Super simple of course. It is really nice to be able to see your application out in the wild!

Pro Tip

The rails generator makes it super easy to create all of the files that you may need for a controller or model. However if you accidentally create a model with the wrong name and your project it huge it can be somewhat daunting to figure out what is safe to remove. You can reverse a rails generated command with:

rails d $TYPE $NAME

So for example, if I created a model called recipeee

rails g model recipeee

I could remove it with

rails d model recipeee

I can see how this will come in handy in the future.

Final Project

The final project is a simple web application called Recipe Finder that allows you to search for recipes using the food2fork api. I cleaned it up a bit and added an actual search bar (the assignment just had you add query params).

Coursera Rails Module 2 Notes

2016-08-12 20:57:05 ][ Tags: rails mooc

Intro to Ruby

This module goes through a general introduction to Ruby. One thing that I find interesting is how optimistic Ruby is, in the sense that everything except for false and nil is true. This is especially interesting from the perspective of comparing true and false in sqlite where sqlite stores 0 as false and 1 as true. I have not had to deal with this yet, but it is nice to keep in mind going forward. Another nice thing that I have not used that much is irb this is basically a Ruby repl that allows you to quickly test out concepts in your shell. I also love (since I work at a CI company) that the very first lesson about ruby talks about rspec and even has us use it go grade our assignments. It is never too early to start thinking about tests.

Tour of Ruby Data Types

The next module took a nice tour of Ruby data types. I learned some pretty neat things.

I also finally understand how blocks in Ruby (closures) work. (After many years of derping through Vagrantfiles)

Object Oriented Ruby

Unit Testing

Again, I love that this course started right off the bat talking about unit testing. A+ to the course creators for covering this topic. The instructor did a good job talking about the differences between Test::Unit, MiniTest, and RSpec with great examples of how to use all of them.


The final assignment for this module was to write a program that reads a file and calculates word frequency. Overall it was pretty simple, I think the material did a good job preparing us for the task, and caused us to use a lot of the different tools that we learned about Ruby.

Parting Thoughts

I have often heard that Ruby was designed for developer happiness. I really love the clean syntax, well documented API, and elegance. The next module will be a deep dive into Rails, looking forward to using more of the stuff that I have learned in this Ruby crash course.

Coursera Rails Week 1 Notes

2016-08-04 19:12:35 ][ Tags: rails mooc

I wrote earlier about how I am taking a series on Rails Development with Coursera. Below are some of my notes from the course:

Installing Rails on OS X

I had RVM installed in the past, but my experience with CircleCI, conversations with eric, and the instructions in the course told me to use something else. So I blew away RVM and replaced it with rbenv. When it came time to install rails, I was getting an error around nokogiri which is strikingly similar to a lot of the issues that we see when updating OS X images. I am not 100% sure what the root cause of this error is, but the fix is to run the following command xcode-select --install this will magically fix everything and rails will install. Apparently this has something to do with when you install newer versions of Xcode, some underlying libraries become sad and running that command fixes it. Yay Apple.

Handy Bash Profile

During the installation videos the instructor shows how to work with bash profile. I stole a couple things from his profile that he did not cover that would have saved me hours over the course of my life so far.

  1. Make the prompt show less info My current bash prompt is super long because my laptop name is Levs-MacBook-Pro-2:, if you set the following variable it will just show you your username:

    # Change the way Prompt Shows Up
    export PS1="\n[\u \W]$ "
  2. Make aliases for ls and ls -al These aliases are super handy. The first one shows you which files are directories, symbolic links, or regular files in color. The second one allows you to list all the details about files by simply typing ll instead of ls -al'.

    # Aliases
    alias ls='ls -G'
    alias ll='ls -al'

These were some useful tidbits from a completely unrelated lesson.

Sublime Text Tips and Tricks

Like many MOOCs these days, this course recommends using Sublime Text. I don't disagree, its a great editor. I bought a license two years ago but have not used it in quite some time. I like it because its super lightweight, has a relatively small learning curve, and is fast. This is especially evident when working with large text files that would cause the latest stream of Electron based editors (like Atom, VS Code, Light Table) to beachball or crash. I decided to give it another shot and follow along in this course. I learned a couple of things I did not know.

  1. If you double click on a search result it will take you to the file, holy crap that would have saved me a ton of time in the past.
  2. Go to Anything with Command + P, I have heard about this but never used it. Wow. Just Wow.

I even picked up Mastering Sublime Text{.add-link} to learn about a lot of the features that I probably do not yet know about. Update: I wrote a blog post with my Notes on Mastering Sublime Text. Still a highly recommended book.


This course had a great overview of Git including a nice historical overview and differences between git (Distributed System) and Centralized Systems like CVS and Subversion. This course also allowed me to discover that Pro Git is available for free as an ebook. This is an excellent resource and I am so grateful that Scott Chacon and Ben Straub released the eBook under a CC license.


My mind has been blown. If you go to any GitHub repo and type in "T" it starts a fuzzy search of that repo. I have been using GitHub for three years and did not know about this feature. This just goes to show you, that even if you are an "expert" at something, it can be really valuable to step back into the shoes of a beginner. I did not expect to learn much from this first module, but I was sorely mistaken.

Become a Rails Developer

2016-08-04 19:11:43 ][ Tags: rails mooc

I am working through this Rails Series on Coursera to get a more structured exposure to the rails ecosystem. I find that I learn best when I have a school like structure, so even though I have been fiddling around with Rails for quite some time now I am hoping that this series will teach me some good patterns for the future.

So far I have been super impressed. First, I had no idea that Johns Hopkins even had a Computer Science department. Second, watching the introductory video on this series made me envy the students in that program. I finished my MS in Computer Science at NOVA Southeastern University last year and although I would highly recommend this program for anyone who wants to learn the intricacies of CS, it is not the best program to prepare you for a programming job. This is not that programs fault but instead a general problem with CS education. Most programs are about 10 years behind in terms of trends, tooling, and practices. However, based on the course intro which was given by the faculty of JHU I feel like they "get it". I am sure that the JHU program is not that much different as far as core content, but the fact that they give their students exposure to real world practices (rails, mongo, git, etc) is inspiring.

I am looking forward to working through this course and becoming a jr rails developer. I hope to apply these skills directly to this project that I started two months ago and have not touched since. Opendesk is an ambitious project to make a support center that does not rely on tags to accomplish anything outside of the "norm". Hopefully be the end of this series I will have enough knowledge and skills to push this project over the edge and make an actual release.

One immediate benefit of this course is that I learned that Pro Git is actually available as a free ebook. This is an awesome resource that really digs into the intricacies of git. I would consider myself an intermediate git user, but there is always room to learn more.