# Editing a form in nested_form gem

This is a very very naive and simple thing but I quite lost my time on this so I thought might be helpful.

Recently I was using the ‘nested_form’ gem by the great Ryan Bates (https://github.com/ryanb/nested_form). The form to create a new form works like a real gem without any effort.

Now, when I clicked on ‘edit’ link, it created some issues as the nested models didnt come.

I had a simple thing like each question has many answers. When I created a question, I added 5 answers to it but when I edited the question, no answers were visible.

The simple solution for this would be that the <% f.fields_for :answers do |an| %> line in your form would be without an equal to sign so just add it.

Thus, it looks like

<%= f.fields_for :answers do |an| %>

Thats all and it works like a charm!

Hope it helps.

# Install apache web server and passenger on Ubuntu 11.04(Natty)

I just Installed apache and passenger on Ubuntu 11.04 to run and deploy my ruby on rails applications Passenger is a gem and can work with apache as well as nginx…

The reason for choosing apache is that its an industry standard.

Also one thing I did with apache was created virtual hosts and ran my apps on local machine with domains like http://www.application1.com

In this post I will list the steps I followed in order to setup apache web server and passenger.

Here is my stack:

•  Ubuntu 11.04
•  ruby 1.9.2 via rvm
•  rubygems 1.8.10

I will be using rails 3.1.10(lastest this morning).!!

So lets start !!

• Install rvm

To install rvm just type the following in the terminal(ctrl+alt+t)

user$bash < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer ) You can find more information about rvm on Here • Install ruby via rvm Once rvm is installed you can install the latest or desired version of ruby by typing the following in terminal rvm install 1.9.2 This will install ruby 1.9.2 on your system. More information on how to make it your default ruby is available on here • Install rails. just need to do gem install rails • Install passenger just do gem install passenger • Install apache web server. To install apache web server type: sudo apt-get install apache2 apache2-mpm-prefork apache2-prefork-dev • Install passenger apache module. Once this is done, we must install passenger , an apache module thats hepls us to rub rails apps on apache. sudo passenger-install-apache2-module • Configure. Finally everything is done. When you run the passenger apache module, there would be some instructions that installer will give you. The last thing it will tell is to paste some text in apache configuration file The configuration file is located at /etc/apache2/apache2.conf Now once this is done, we are ready to deploy. This has a lot of information about deploying. In my next post, I will show how to start rails apps on local machine with apache. Hope it helps.! # A candid interview with Society !! It feels so great !!! Amitabh bachchan in Hindi movies or clint eastwood in the 70s and 80s revolting against a society !!! Wow, I hope I can be such a hero too ! Speak dialogues in front of an idol like vijay or fire a gun like eastwood does !! Was it only the greatness of Salim-Javed and sergio leone( not related to sunny leone i presume!!) or we need such rebellions ?? I think like our economy , our society and our value system is at an all time low !!! We are in midst of a moral recession. Look in the mirror ! What are we doing ? Where are we headed ? Whats our objective ? whats with us ?? This is what I felt. So, I decided to take an interview of the society on four basic factions of life. Childhood, youth, parents and old age. Here are the views of society on these factions in a summary: We first talk about childhood. O ! childhood is an age of innocence. It is that period of life when everything is so beautiful. What are your views ? O yes, child hood is a great phase of life. Probably the greatest. Now, what I do with childhood is very simple. For me , childhood is not a phase, to enjoy, childhood is a phase where I can impart value system in that small brain , or thats what people call that first floor of humans. I impart the knowledge like we believe in only a particular god. The choice of god varies depending on my wish. If I am Christian, I say, jesus is the true god and others are not. If I am a hindu, I say Shiv or Krishna is a true god nothing else. If I am islamic, I say Allah is path to salvation and nothing else. So I impart this invaluable knowledge to them. See, I am doing this for them . I am training them to fight for rest of their lives. If this is not taught, how will they fight ? What will they do ? Then I also somehow manage to convince them that the scriptures are very very true. They are very literal and you have to believe in miracles. That actually easy as they do not much about science at that time and to tell you a secret, I also tell them that of they ever ask me a question, they will be punished !! Isnt it cool ? Then, I send them to school ! There I give information and tell them that this is knowledge. Those poor little beings believe it !! They actually think school and college is a place where they get knowledge. This is a greatest failure of knowledge isnt it ?? (hehe). Then when they say they have gained knowledge , I ask, how do I know. Prove it by getting good grades in the exams. Memory is the path way of knowledge for them and this I think is a very innovative idea by me. This is imparted in the human brain and is executed through out. Humans, stupid humans actually believe that intelligence is knowing things. In IO test, they ask some questions regarding who was who and who did what and when etc ! And they test their intelligence !!! (Hahahahahahha). Anyways, then is gradually expose them to outside world. I show them movies, give them books etc. I show them shows like “mahabharat” or “jesus story” and tell them television is true. But this has a side effect, when they see things like “original sin”, “ma mere” or “munni badnam” and “sheila jawan”, I scold them. I say thats not what you should learn. Though I allow the makers to make it and elders to watch it, but not for children.Some say what is does is confuses a childs mind, but I say, no, the only rule is follow my rules without question !! Thus, in childhood, I impart qualities like competition, rivalry, winning spirit and also gifts. I give gifts when you are successful and punish when you fail !!! Then comes youth. Another good phase. Human at his/her prime in the life. Full of energy and enthusiam ! What about it.? Well, yes, youth is a good stage. Its a good platform to teach advanced things now. Now, in this stage, I introduce them to money. I give them money but not the permission to spend it. So, they are confused. Then I tell them whats good and whats bad without reasoning ! I say, drugs are bad. Not why are they bad. Ofcourse, as god has made humans curious , they wanna know why are drugs bad and hence consume it. Thats it, as soon as they consume it, I proclaim them as sinners. I punish them and I isolate them. The result, they take more drugs. And computer scientists thought recursion is their invention !!! Then for someone who has escaped this devious and brilliant plot, I surely trap them in marriage. See, I am a humanitarian, I allow you to love. But, as usual, the catch is you cant marry the person you love. There are things like cast and creed that I have to take care of. And then, I fill the human mind with the root cause of all troubles. “Expectations”. I teach them to expect from the person they wanna marry.I teach them: We are the invincible ones. We are the most popular ones.Each and everyone needs us you see.But ofcourse, we are also humans and we have our requirements. We look into some basic qualities in our partner. Common, they are not very difficult. We are good people you see. All we expect is that the partner should be good looking. Have a good figure/physique. They should have style you see. We need it as when we introduce them to our friends, our style and status should be maintained. He/she should know how to behave in a 5 star hotel and should know how to speak in english full of accent, How to drink wine and how to hold hands and dance in a party. He/she should like my friends and appreciate my habits. Even If I smoke, He/she should not. Even If I flirt with someone else, he/she should be faithful. Even if I do not give a damn about my parents, he/she should. Even If I courier her/him a gift, he she should be happy ! Thats all we ask for. Nothing more. And ya, ofcourse, they should not be married before. You see we need “fresh” people. And ofcourse, I many cultures, marrying a divorcee or widow is a crime. And kinda Post script: Their fathers must be rich. They should be able to fulfill our dreams ! I dream of buying a car and since I am a divine being, he should full-fill it as a duty !! Thats all, see how nice we are !! See, isnt it good ?? Isnt it correct ?? I know I am a master, I can make it from your expression kid !!! Then comes parenthood. gift of god! A birth of human life. How do you deal with that. I start by seeing them cry. They cry when in the hospital, they hear the crying of the baby. But, for me , its an important phase. I start early. I say, if the baby is a girl, then you ought to cry you idiot ! How can you do this. Girls , I somehow manage to convince the people , are not creation of god. The idiots believe me. They know their mother is a girl still in many times and cultures I have convinced man to kill girl !! I love it. But I do not stop there. Then there is a simple course for parents. Thats actually a result of what I thought in childhood. Rivalry, competition etc. Now the concepts are applied to children. The average guy is always told “learn from your brother/sister”. Isnt it ?? Now, I dont see anything wrong in it ! Ofcourse, studies and grades are everything ! People not good at studies or those who do not get good grades should understand that they have a responsibilities toward their parents ! What will their parents say to the relatives and neighbours ?? What do they talk if you do not top or you do not win a trophy on your sports day ?? ow will they say ” see this is my sons certificate” with a proud laugh on their face and a hidden feeling a achievement as the relatives son stood second !! Guys , we have to understand that world war 3 is all parallel ! Each house and family has its own version of world war 3 !!! Common, you cant be average !! But what do we actually learn in school, college ? Its just information anyways. Knowledge is long lost when we used memory to test intelligence. How great of me that we expect our students to understand information !! One may ask how do you understand that a flight AI-103 is going from Bombay to London !! Isnt it same as teacher after teaching a chapter on Gandhi asks “Understood ” ???? Today I care more about translation of gita rather than understanding it !! Then comes old age ! Probably the most difficult phase of life. All traditions and religions in the world say we should respect our elders ! So I do. We make better old age homes ! I give them better facilities. I give them a garden to have an evening walk with those artistic looking sticks I gave them as birthday present and those arthritis inflicted legs which nature gave them. I give them library. Books to read with those armani glasses I gave them and those eyes that cant see clearly which nature gave them. I give them cozy beds and heaters or Air conditioner so they can sleep properly forgetting that only closing eyes is not sleeping. I give them smart phones to stay in touch ! So they can contact us when in need ! Knowing that those shaking hands cannot dial or remember the number !! We give them good medical facilities so they do not feel any pain. I give them medicines as their blood pressure increases when going to a doctor. They say, they need their children. Are they mad ? They are busy ,they have a meeting to attend otherwise their company would go bankrupt. they have their car to be serviced, they have wine to be purchased, they have extra language classes to attend, they have gym to go , they have to go to the temple or church for worship ! They are so so busy! common, tell oldies to handle themselves. And then they say, all we need is your smile and I say, na I cant, I have to mourn for a train accident victim you see !. All they ask is can you spend one hour on a sunday and I say no,I have to go for mass and feed the homeless !! The old people must understand, I dont have time for their stupid emotions. I will talk to you only if the talking helps my bank balance in any way ! I do this much for them , be content with what you get. You get free money. What else do you need ?? Mr. Society, Arent you afraid of god ? God ? Hahaha, tell me whats god? How did you came to know about the concept of god ? Its through me child. I created god. And god, where is he ? Can he do anything ? I am the one who stays with you everyday, every minute !! I am the one with you, always. I have been with you for ages and I will be with you forever. I am a parasite which eats you, which consumes you and you do not have a medicine for me. You cannot harm me. You cant live without me you see. After all, you are a social animal !!! The Mayans said that world will end in 2012. While factually incorrect, I suppose they understood the parasite I am talking about. A cancer, my interviewer friend kills you. I on the other hand give you life. Its true that I have now grown so so strong that living with a parasite like me is more difficult than getting killed by a cancer !! # Fixing Ubuntu GPG BADSIG error Recently, I faced a error while updating my Ubuntu system. When I ran “sudo apt-get update”, it gave me the followinf error message: W: GPG error: http://archive.canonical.com intrepid Release: The following signatures were invalid: BADSIG 40976EAF437D05B5 Ubuntu Archive Automatic Signing Key The way I fixed it was:$ sudo -i

# apt-get clean

# cd /var/lib/apt

# mv lists lists.old

# mkdir -p lists/partial

# apt-get clean

# apt-get update

Hope it helps. !!

# Changing the text color of your Icons on Desktop in Ubuntu

Recently. I encountered a weird requirement.

I had changes my background image to a white colored image due to which the text on the icons was not visible.

Thus I wanted to change the text color of the icons on Desktop to black.

It turns out that is fairly simple.

Here are the steps :

Go to

NOTE: I use the radiance theme and hence this path. In case you are using a different theme, replace “Radiance” with your theme name.

Here open a file called as “nautilus.css” in a simple text editor.

Somewhere near line 8-10 , there is a desktop mode where you can make your changes.

Find the line

color:@bg_color

Instead of removing it, comment this out and below that, copy the same line and use the hex code of the color you want to use.

For example, in my case it looks like:

color:#000000

Not a big deal but hope it helps !!

# Compiling a LaTeX Document.

So having prepared your first tex document I was pretty excited to see the out put. But there was one daunting question !!
Whats the next step ??

Fortunately , I was using KILE so I got my PDF in a click but I wanted to figure out how get the same pdf using command line.
So here is the procedure to do the same:

—————————————————————————————————————————————

STEP-1:

Suppose the file my_report.tex” is the file that contains all the author’s work, i.e., her actual typed words and formulae. It was typed using the text editor vi. Similar text editors include emacs, pico, Notepad (in Windows), and TextEdit (on Macs).

First navigate to the place where the tex file is located using terminal.

Then run the command:

latex my_report.tex

This produces a bunch of files. One of them would be my_report.dvi.
The dvi stands for “device independent”.

The file my_report.dvi is the same regardless of

(1) which computer is used to compile the document,

(2) what kind of printer it is headed for.

In fact, it is too universal to be printed in this form; it must still be translated to a form suitable for a specific kind of printer. (Different printers speak different languages…) You can’t even view the DVI file unless you use a special “DVI Viewer”, such as xdvi on ucsub.

The files“my_report.aux” and  “my_reoprt.log” are two by-products of the compiling command.
The aux file is used if the document contains more complicated stuff, like bibliography and cross-references.

The log file contains a full record of the compilation, including errors you need to correct, e.g., misspelled macros, missing bracket or parenthesis, missing references, etc.

—————————————————————————————————————————————

STEP-2:

The file “my_reoprt.ps”, a PostScript file, the kind understood by most laser printers.
A printable PostScript file is created from the dvi file by the translating program dvips. On computer run the command

dvips my_report.dvi

—————————————————————————————————————————————

STEP-3:

The file my_report.pdf” is the PDF form of the document.
This is as web-friendly a document as possible. Using Acrobat Reader, any computer can be used to view the document and/or print it. On computer run the command the command

dvipdfm my_report.dvi

translated the DVI file to PDF form.

Thats it !!

Hope it helps. !!

# Special Characters and Symbols in LaTeX

Following is the way to use special characters and symbols while creating a document using LaTeX:

Symbol/Character Way to get it in LaTeX
Quotation Marks two ` (grave accent) for opening quotation marks.
two ‘ (vertical quote) for closing quotation marks.

Dashes and Hyphens L TEX knows four kinds of dashes. Access three of them with different number
of consecutive dashes. The fourth sign is actually not a dash at all—it is the
mathematical minus sign.
The names for these dashes are: ‘-’ hyphen, ‘–’ en-dash, ‘—’ em-dash
and ‘−’ minus sign.

Examples of each are shown below:

• daughter-in-law —-> daughter-in-law
• pages 13–67 —-> pages 13–67
• yes—or no? —-> yes—or no?
• $0$, $1$ and $-1$ —-> 0, 1 and −1
Tilde (∼) $\sim$demo
Slash (/) \slash
Degree Symbol (◦)

^{\circ}\mathrm{C}\$.
The textcomp package makes the degree symbol also available as \textdegree
or in combination with the C by using the \textcelsius.

The Euro Currency Symbol

\texteuro

NOTE: its available in textcomp package

Ellipsis (. . . )

On a typewriter, a comma or a period takes the same amount of space as
any other letter. In book printing, these characters occupy only a little space
and are set very close to the preceding letter. Therefore, entering ‘ellipsis’
by just typing three dots would produce the wrong result. Instead, there is
a special command for these dots. It is called

\ldots

Ligatures

Some letter combinations are typeset not just by setting the different letters
one after the other, but by actually using special symbols.

These so-called ligatures can be prohibited by inserting an \mbox{} between
the two letters in question. This might be necessary with words built from
two words.
example:

1 \Large Not shelfful\\
2 but shelf\mbox{}ful

1.Not shelfful
2. but shelfful