About Git

Found a really nice post about Git by MyWayOnRails (see above). Git is the predominant source controle solution (in my opinion) and I highly recommend it. I also recommend using Github, as it allows you to pull or commit your source code anytime, anywhere there is a wifi connection, which is excellent for me as I work predominantly out of coffe shops. I also feel software companies will continue to embrace telecommuting as a viable option for their employers, which makes source control systems like Git essential to learn.


Git is not inherently a traditional source code management system. Git can be rather said as a “Personal” source control system. By “personal” it means it doesn’t require any server to store the code, can maintain the revision records on the personal computer only.

Unlike in SVN, where all the changes are stored in a remote central server, in Git there is no concept of server. In git all the code or data is stored at all the user ends, each end user will have complete copy of the repository along with the history of changes.

View original post 883 more words

Tagged ,

Could Not Parse Yaml, Why!?

Yaml config files are a great way to store static data in your rails application. But there’s a little caveat I experienced today. Observe the following yaml file:

  "golden retriever"

Looks fine, right? Now let’s assume you’ve named this yaml file dog.yml and it lives in your application’s config directory. You’d figure you could access the data by doing something like the following:

puts config (yields the hash {"dog" => { "poodle", "husky", "golden retriever" } }

But for whatever reason, you are getting an error (couldn’t parse YAML at line x column x). You suspected that “golden retriever” might be a problem due to the space, but you’ve already quoted it, so no, it can’t be the problem.

Continue reading


Basic Controller Rspecs


Suppose the following method is there in the controller

def new
  @post = Post.new

For this the corresponding spec will be as follows

describe "GET #new" do
  it "creates new instance of post" do
    get :new
    assigns(:post).should be_a_new(Post)

In the above code “get :new” line will get the new path of the controller and execute the corresponding method described in the controller. So that particular statement is very important for execution of the method and comparison of the output in the test.

View original post 458 more words

Auto Generate Factories for your Models

My good friend and colleague DS filled me in on a little trick that I’d like to share. When testing, it’s a good idea to have factories written for each model. Now, if your model is already created, you’ll have to spin up that factory manually. But how about ensuring your factories are created with each new model you generate?

Enters this nifty bit of code you can add to your config/application.rb file, within the Application class:

Continue reading

Name Those Classes Properly

Although it may not seem intuitive, Rails is very picky when it comes to how you name your files, specifically  when adding new classes within your app folder.

Let’s say you have a class that looks like this:

class MySuperCatHelper

   def meow
      puts "Meow!!"


You’ve saved this class in the app/helpers directory in a file called my_supercat_helper.rb. Naturally, you want this class to be available to your MySuperCat controller where you wish to add the following code:

cat = MySuperCatHelper.new

But for some reason, you’re getting an error about an uninitialized constant when using the above code in your MySuperCat controller.

Why is that?

Continue reading

Rake Tasks

With any web application, you will find yourself needing to run ‘behind-the-scenes’ tasks. In the .NET world, I often found myself writing scheduled tasks to run on app servers, or utilizing Taskie to accomplish these goals. But with Ruby on Rails, you’ll find yourself writing Rake tasks.

Continue reading

Tagged , ,

Rails pagination, will_paginate, and AJAX

One of the beautiful elements of Ruby on Rails is how much you can do with so few lines of code. The will_paginate gem is a prime example. With just a few line’s of code, you can add pagination to any of your application’s lists. Having dealt with home brewed pagination methods many times during my years as a web developer, I can only say that this little gem has brought me much joy. Below is an example on how to use it.
Continue reading

Tagged , , ,

Responsive Design

My wife, daughter and I visited a friend/coworker over the weekend. We had a wonderful time getting to hang out with him and his wife, letting our nine month old roam their 1850’s plush carpeted farmhouse, and exploring the ancient basement, home to a toad, cobwebs, and chiseled stone walls.

But the day would not have been complete without my friend and I sitting down and coding some Ruby on Rails.

As he and I discussed the apps we’d been working on, I showed him a little about the Rails asset pipeline (will post about this in the future), while he showed me how he’d used a nifty css/javascript framework to set up responsive design for his site.

Continue reading

Tagged , ,

Critical Rails Security Issue

In January 2013, I was informed from a colleague about a severely critical security hole in nearly all Ruby on Rails versions. Although I’d read about the issue a couple weeks prior, I didn’t think I had to immediately worry about making the necessary upgrades to the patched versions, because all the Rails applications I was currently working on were still only in development modes, and running on local workstations under localhost. But then my colleague sent me a link to the following article (if you develop Rails applications, please read it):


Hopefully, you noticed from the article that even development applications running under localhost are vulnerable to this security breach. Continue reading

Tagged , ,

Rails Mass Assignment Error/Security

When creating a form in Ruby on Rails, you’re offering an end user a way to save data to your database. But that end user could be anyone. It could be someone who is using your site as intended, or, someone who is trying to hack into your system and ruin your life.

Continue reading

Tagged , ,