Skip to content

completely remove a file from a git repository

i committed  site path configuration file into git repository in my drupal module. After some commit only i created the gitignore  file and add  path configuration file into gitignore. I have to remove that configuration file from my  previous commit also. To do that just to :

$ git filter-branch --tree-filter 'rm -f my_file' HEAD



php display errors output

If i run PHP code with some error, it says server not found or displaying blank page, it is not displaying the error.


To display error output we need to change display_errors = Off   to  display_errors = On in php.ini file.

Once any changes made in php.ini file must restart the Apache server. Then only the changes will update.

inherited_resources In Rails 3.1


i am working with “inherited_resources” gem today. First read


Create Nested Form in Rails 3.1


While we creating some forms, also need to create some additional forms. In rails can easily create those type of form using gem “nested_form”. It can  manage multiple nested models in a single form. To know more

can see how it works

i have two model name Project,task. Project has many task. i want to create multiple task when create a project.

include gem in Gemfile

gem "nested_form", :git => ''

then run command in  project directory

$ bundle install

This gem add new  nested model by using JavaScript. it automatically create JavaScript file.To create JavaScript run this command

$ rails g nested_form:install

now one file created in public/javascripts/nested_form.js

copy the nested_form.js  to app/assets/javascripts/

if your server is running restart to load new installation.

set controller and model like


class ProjectsController < ApplicationController
def index

def new

def create[:project])
flash[:notice] = "Successfully Created project."
redirect_to projects_path

def edit

def update
flash[:notice] = "Record Successfully updated"
redirect_to projects_path

def destroy
redirect_to projects_path


in project.rb

class Project < ActiveRecord::Base
has_many :tasks, :dependent => :destroy
attr_accessible :tasks_attributes,:name, :description
accepts_nested_attributes_for :tasks, :allow_destroy => true

validates :name, :presence => true

in task.rb

class Task < ActiveRecord::Base
belongs_to :project

in my views/projects/_form.html.erb

<%= nested_form_for @project do |f| %>

<%= f.label :name %>
<%= f.text_field(:name) %><br />
<%= f.label :description %>
<%= f.text_field(:description) %><br />
<h3> Tasks</h3>
<%= f.fields_for :tasks do |task| %>
<%= task.label :name %><br />
<%= task.text_field :name %><br />
<%= task.link_to_remove "Remove this task" %>
<% end %>
<p><%= f.link_to_add "Add a task", :tasks %></p>
<%= f.submit %>
<% end %>

f.fields_for :tasks render the partial file “task_fields” create  partial file name as _task_fields.html.erb in views/projects/

and include the nested fields.

while click “link_to_add’, “link_to_remove” it calls the addField removeField in nested_forms.js file.

Nested form fields are added via javascript.


Animeted Menu Bar


i am learning css, i created simple Animated menu bar, let see

first create the menu link like

<title>Testing menu</title>
<link rel="stylesheet" href="reset.css">
<link rel="stylesheet" href="menu.css">
<div id='container'>
<div id='navbar'>
<li><a id='image1' href='#'>Image1</a></li>
<li><a id='image2' href='#'>Image2</a></li>
<li><a id='image3' href='#'>Image3</a></li>
<li><a id='image4' href='#'>Image4</a></li>
<li><a id='image5' href='#'>Image5</a></li>
<li><a id='image6' href='#'>Image6</a></li>
<li><a id='image7' href='#'>Image7</a></li>
<li><a id='image8' href='#'>Image8</a></li>

i included here reset.css. This css used to reset all the default properties for the element. Then we write the our own css to over write the existing css setting.

in my reset.css

html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, font, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td {
margin: 0;
padding: 0;
border: 0;
outline: 0;
font-weight: inherit;
font-style: inherit;
font-size: 100%;
font-family: inherit;
vertical-align: baseline;
/* remember to define focus styles! */
:focus {
outline: 0;
body {
line-height: 1;
color: black;
background: white;
ol, ul {
list-style: none;
/* tables still need 'cellspacing="0"' in the markup */
table {
border-collapse: separate;
border-spacing: 0;
caption, th, td {
text-align: left;
font-weight: normal;
blockquote:before, blockquote:after,
q:before, q:after {
content: "";
blockquote, q {
quotes: "" "";

In my menu.css file

line-height: 83px;
li a{
text-indent: -999em;
li #image1{
background-position: 0px 0px;
li #image2{
background-position: -46px 0px;
li #image3{
background-position: -98px 0px;
li #image4{
background-position: -171px 0px;
li #image5{
background-position: -241px 0px;
li #image6{
background-position: -300px 0px;
li #image7{
background-position: -382px 0px;
li #image8{
background-position: -438px 0px;

li #image1:hover{
background-position: 0px -83px;
li #image2:hover{
background-position: -46px -83px;
li #image3:hover{
background-position: -98px -83px;
li #image4:hover{
background-position: -171px -83px;
li #image5:hover{
background-position: -241px -83px;
li #image6:hover{
background-position: -300px -83px;
li #image7:hover{
background-position: -382px -83px;
li #image8:hover{
background-position: -438px -83px;

This image i used to show animate

It is not hard. First i set this image to link background, then i only change the image position for every link.

that’s it..:)

Do it while move mouse on the image it show as animation. like above images..


Create a Custom Blocks in Drupal6


i just go through the hook_block and create a custom block in drupal 6. The custom module file as follows,

The file as

; $Id:,v 1.0 2011/10/04 19:32:28 Exp $
name = custom
description = this is my custom test module.
package = custom modules
core = 6.x

The custom.module file as

* Implementation of hook_block()
function custom_block($op='list', $delta=0, $edit=array()) {
switch ($op) {
// Declare the list of blocks to create
case 'list':
$blocks = array();
$blocks['custom_block1'] = array(
'info' => t('custom_block1 information'),
$blocks['custom_block2'] = array(
'info' => t('custom_block2 information'),

return $blocks;
// in this case assign the content for the listed block
case 'view':
switch ($delta) {
case 'custom_block1':
// assign the value for the custom blocak one.
$block = array(
'subject' => t('Title of custom block1'),
'content' => "content of custom_block one" ,
case 'custom_block2':
// assign the value for the custom blocak two.
$block = array(
'subject' => t('Title of custom block2'),
'content' => "content of custom_block two" ,
// all the value of the block passed in this variable $block
return $block;


Make the both files in custom folder as past the module in /sites/all/modules/custom. Install the custom module, now the two custom block created in block like

Now assign the blocks to region required region. i assigned the blocks to right slider bar it shows block content like



Create a Custom Region in Drupal6


i created a custom region in drupal6. i used the Zen based Airyblue Theme.

Default available region in this theme included in file. If is not available in this file, you first include the available region.

regions[sidebar_first]  = first sidebar
regions[sidebar_second] = second sidebar
regions[navbar]         = navigation bar
regions[content_top]    = content top
regions[content_bottom] = content bottom
regions[footer]         = footer
regions[closure_region] = closure

i add the new custom region in file name as “header-right” like below

regions[sidebar_first]  = first sidebar
regions[sidebar_second] = second sidebar
regions[navbar]         = navigation bar
regions[content_top]    = content top
regions[content_bottom] = content bottom
regions[footer]         = footer
regions[closure_region] = closure
regions[header_right] = header-right

now the new region display in block. Then where you want the new custom region to appear in your page, included in page.tpl.php. i include the block below the header.

<?php if ($header_right): ?>
<div id="header-right"><div id="header-right-inner">
<?php print $header_right; ?>
</div></div> <!-- /#header-right-inner, /#header-right -->
<?php endif; ?>

Write the css for this

float: right; /* LTR */
width: 120px;
margin-top: -87px;
margin-left: 0; /* LTR */
padding: 0; /* DO NOT CHANGE. Add padding or margin to #header-right-inner. */


margin: 0 18px 0 0; /* LTR */
padding: 0;


Now the new region displayed in the top right corner like,

now assign the block for this region. It will show like



Get every new post delivered to your Inbox.