Welcome Message

Welcome to Aslam's Buzz. Here you can find a lot of useful articles related to the latest web technology which I come across being an application developer.


Follow on Tweets

Blog moved to TechSlam.Net

Posted in


This blog has been moved to new permanent domain at TechSlam.Net. All further posts will be in this new domain. So see you there. Thanks :)

A Long Gap

Posted in

It's been a long time since I had any post in my blog. Been quite busy. Yes lot of things happened in the mean time and I need to get back to the track. Rails 3, Wordpress 3 etc. I have to update myself with these and get started again.

Meanwhile I have come across a wonderful learning resource on Rails 3 which I would like to share with everyone. It seems to be quite good to get your feet wet on Rails 3 :

Learn Rails by Example
By : Michael Hartl

Ruby Twitter Gem : Usage in Rails Application

Posted in , ,

In my current project, there was a requirement to show the latest tweet in the home page and also an interface to send tweets from the same rails application using a particular twitter account.

A quick Google search showed maximum results on a gem named 'Twitter'

here in this post I am going to use this gem to pull the latest tweets as well as, implementing a simple interface to send tweets directly.

There are wide possibilities using this gem, like, you can follow friends, unfollow friends, delete tweets, send direct messages, create lists etc etc.

So first of all Install the gem:
gem install twitter

If you have created a test rails application, create a new controller and name it as 'TwitterPublish'
ruby script/generate controller twitter_publish
Now add the following code to your newly created 'TwitterPublishController'
Controller TwitterPublish < ApplicationController

  require 'rubygems'
  require 'twitter'

  def tweet
    httpauth = Twitter::HTTPAuth.new('twitter_username',  'password')
    @user = Twitter::Base.new(httpauth)

In the above controller code, provide the required twitter login details.

Next create a tweet.html.erb file within app/views/twitter_publish

and paste the following code :
<% @ user.friends_timeline.each do |tweet| %>
  <%= image_tag "#{tweet.user[:profile_image_url]}" %>
  &nbsp; <%= tweet.user[:screen_name] %>&nbsp;<br/>
  <%= tweet.text %><br/>
<% end %>
Now if we run the server, and check out the link http://localhost:3000/twitter_publish/tweets , we will find all the latest tweets from the people I am following will be listed down along with their image.

Next, we need a text box in the same view isung which we will be able to tweet directly.

add the following code at the top of app/views/twitter_publish/tweet.html.erb :
<% form_for :twitter do |t| %>

  What's happening ?

  <%= t.text_field :tweet %><br/>

   <%= t.submit "Tweet" %>

<% end %>
And to create the update we send as tweet through the text field, we have to add the following code to our tweet method in TwitterpublishController:
if request.post?


  redirect_to :action=>'tweet'

That's all, you can now tweet directly from your rails application.

I have also come across another gem for the same purpose named 'Twitter4R'

Have you tried this gem out ?

Do share your views on both the gems.

Book Reviews : BukLuv.Com

Posted in , ,

Are you a book lover ? Do you like to share reviews about the books you have read or are you looking for some reviews on certain book you are planing to read ?
BukLuv is the platform which will answer all these questions straight away.
BukLuv is a web application which is dedicated to the book lovers.  After registering with this site, you can go ahead and share your reviews about the books you have read and if you do not find the book after searching through the site, you can add the book to the system along with the review. There are many other features and you can get to know it completely from BukLuv Blog. This web application is built using Ruby on Rails framework and is hosted at HostingRails .

Myself along with my friend Nithin always wanted to come out with a web application of our own and we used to brainstorm most of the spare-time we get. And finally the idea of book review application sounded quite cool. And we wanted to make the concept of book review out of the box compared to usual book reviewing websites out there and hence the concept of Mini-reviews where user can write reviews with 250 character limit. Once initial plan for the development was set, we began with the implementation. BukLuv was live on march 15th 2010 and after a month with the help of web-developer and a friend of ours Jaseem, we were able to launch much improved version of BukLuv on April 15th 2010. We have got some positive feedback’s on the application and are looking forward to bring many book lovers into this to get to know their feedback’s on the application.

So far so good. But bringing the application into the notice of wide audience is a real task ahead and we are doing our best to achieve it via social media marketing. Check out the twitter page of BukLuv at http://twitter.com/bukluv and the facebook page here.

Feel free to share your views about the application with us and also help us spread the word with the world book lovers community.

My new domain is at Aslam'sBuzz


RubyConf India 2010- Impact on a Newbie

Posted in ,

RubyConf India 2010 was one great success. Two days of valuable experience. I am a newbie to the Ruby Community. And I must say, this community rocks. With its wings starting to spread over India, it is indeed going to make a deep Impact. This Ruby Conference gave me and my friends an oppurtunity to interact with some of the great programming geeks of the world, like Ola Bini, Obie Fernandez, Nick Seiger, Satish Talim to mention a few. They are a real insipiration to a newbie like me.

Find the Full Post at the new domain of Aslam's Buzz at HERE

User Verification Using Rails AuthLogic Gem

Posted in , ,

So here comes the month of march. You must be thinking what's so special about March and if you have started thinking about the same, well, please do let me know if there is anything special about March. For now, let me get the things straight for this post.

Few months ago(I assume in January 2010), I had written a post on Rails gem called "AuthLogic" for the purpose of user authentication.

Here is the link for that post if you do not know, what is AuthLogic all about.

With the help of AuthLogic, we created a beautiful user registration and login/logout features for a web application. Here, when a user registers, on successful registration he will instantly get logged in. But in most web application, that is not the case, We need the registered user to verify his account before his account is activated, and for that, we need to send a verification email with verification related info to the user. So in this post I will be giving you all the necessary information with codes, on how this feature can be achieved.

Add the following codes to your Model "user_session.rb"

class UserSession < Authlogic::Session::Base

validate :check_if_verified


  def check_if_verified
    errors.add(:base, "You have not yet verified your account") unless attempted_record && attempted_record.verified


What this does is, when user tries to login, it will check if the user is a verified user or not. Well, so how do we know if the registered user has verified his account or not? Yes, we have to create a new field in our User Table. Here is the migration file for doing that:

class AddVerifiedToUser < ActiveRecord::Migration

  def self.up
    add_column :users, :verified, :boolean, :default => false

  def self.down
    remove_column :users, :verified

On migration, new field called "verified" of type "boolean" will be added to the User Table in our database. Next, we will look into our controller which is responsible for creating a new user while user registers through our registration form. Well, while registration, the "create" method of "UserController" comes into the action, so we need to edit this file for sending verification information to the user's email:

def create
    @user = User.new(params[:user])
    if @user.save
      flash[:notice] = "Registration verification email sent.Please verify your account."
      redirect_to root_url
      render :action => "new"

what does line number 4 does? it call deliver_user_verifications! method on the user object. So we need to create a new method in our "User" model:

def deliver_user_verification_instructions!

Here in this method we see that "user_verification_instructions" method of class Notifier is being called. So we create that method in models/notifier.rb file

def user_verification_instructions(user)
    subject    'User verification instructions'
    recipients user.email
    from       'XYZ Notifications'
    sent_on    Time.now
    @body[:url]  = "http://test.domain.com/user_verifications/show/#{user.perishable_token}"

Ok, so you now know, what "user_verification_instructions" method of "Notifier" class does. It sends the email to the user. This method will look for a file called app/views/notifier/user_verification_instructions.erb so let us create it

You have created an account for http://domain.com
Please follow the link below to verify your account and get started with XYZ

<%= @url %>

If the above URL does not work try copying and pasting it into your browser.
If you continue to have problem please feel free to contact us. 

here the variable "@url" will have the link which we have given as subject previously. This is how your mail will look:

So from the link, we know, it looks into "show" method of "user_verifications" controller. We will have to create this controller with following codes:

class UserVerificationsController < ApplicationController

  before_filter :load_user_using_perishable_token

  def show
    if @user
      flash[:notice] = "Thank you for verifying your account. You may now login."
    redirect_to root_url


  def load_user_using_perishable_token
    @user = User.find_using_perishable_token(params[:id])
    flash[:notice] = "Unable to find your account." unless @user


here there is a "before_filter" which will check if the link is valid. if valid it will read show method. The show method needs to verify the user. It is done by the "verfiy!" method which needs to be created in "User Model"

def verify!
    self.verified = true
That is it. On successful verification, the verified field gets a value of one and thus, user will be able to log in. So have you guys tried any other ways of doing this. Please share your ideas with me.