Skip to main content


Showing posts from September, 2011

Deals You Can't Miss

1 Year Subscription

Can't find first MyFreakingActiveRecordModel

Can't find first MyFreakingActiveRecordModel.... Do you get this weird sounding error on running your spec for the model? A re-look at the exception should give you some cues. Yeah, it only implies that you don't have a test record for that model in your test environment DB. All you need to do is add a test record to the test DB. If you are using FactoryGirl, and RSpec, the code snippet below shows the way it can be done elegantly. Lesson: Shoulda requires a record in the DB, well atleast in this case :P

Rails 3 - Filtering Sensitive Parameters From Being Logged

If you are wondering, "How on earth do I ensure that sensitive parameters are not logged anywhere by the Rails 3 application?". Well, its a cinch as far as Rails goes. All you need to do is add all your sensitive parameters to filter_parameters list in config/application.rb file. A sample Rails3 config file having this setup will look as below (MyRails3App is the name of my rails application):

Untrack a file in Git

git rm --cached <file>  The good thing about this command is that it will merely remove the file from the history tracking index. The local copy of the file will not be removed. The story in detail...learning by experience [practice]$ mkdir myproject [practice]$ cd myproject/ [myproject]$ git init Initialized empty Git repository in /home/karthik/MyRubyProjects/practice/myproject/.git/ [myproject(master)]$ git st # On branch master # # Initial commit # nothing to commit (create/copy files and use "git add" to track) [myproject(master)]$ touch abc.txt [myproject(master)]$ git st # On branch master # # Initial commit # # Untracked files: # (use "git add ..." to include in what will be committed) # # abc.txt nothing added to commit but untracked files present (use "git add" to track) Situation 1: If you were to untrack a newly created file that you added to staging for commit. [myproject(master)]$ gi