Setting method parameter in form_remote_tag in RESTful setup

June 16, 2007 6 comments

By now, I gotten used to reading the codes if the Rails api documentation is not clear enough.

If you are using Rails in a RESTful setup, and using form_remote_tag, or any other methods that generate a AJAX request, then you might encounter this problem.  RESTful requires you to understand that to get a listing of information, you’ll need to use a HTTP GET method.   If you do not specify the method during the form_remote_tag call, the default HTTP method is POST.  So when the AJAX request is called, the Rails engine will interpret it to be a “Create” call, and the “create” method in your controller is used.

You will get a nasty mess…

Actually the way to set the method in your AJAX request is quite simple.  Just include :method => ‘get’ in your options hash.  For example:

form_remote_tag :url => {:action => “index”}, :html => {:id => “people_filter_form”}, :method => ‘get’

My problem was to put it in the :url hash, or :html hash.  Won’t work. 🙂

Categories: Ruby on Rails

My mum the Qigong Master III

May 30, 2007 1 comment

My mum went to China (Li Jiang) recently, and at an airport for transit, she bought a book to pass boredom.  The author of the book is a doctor whom took over his father’s thesis on how people with different blood types are affected by their diets.   In the book there was a mention that people with blood type A and AB have more difficulties in expelling toxins from their systems, hence most people with ailments are of those blood types.

Now my mum asks her patients what blood types they belong to when they come for their regular massage and qi-gong sessions.  She was very surprised to learn that most of them do belong to type A and AB.  Now she’s advising us what to exclude from our diets.  Fortunately, mine is contained to only chicken and tomatoes.  Unfortunately, one of the best Singapore food is Hainanese Chicken Rice.

Categories: Chatter

Reserved words in Rails

May 30, 2007 15 comments

Oh the agony… I just spent half a day agonising over a new model that I created, and didn’t work when I was doing a find for a record. Just because one of the column name is a named after a reserved word! The error was an obscure:

SyntaxError: compile error
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.2/lib/active_record/base.rb:1359: syntax error, unexpected tINTEGER

So I dedicate this blog entry to the listing of reserved words in Rails. If anyone else has come across any other reserved words that gave you hell, please comment!

Reserved words for Rails’ ActiveRecord
  • type
  • integer
  • string
  • text
  • file
  • number
Reserved words for Rails’ ActiveController
  • template ( Someone mentioned this on the Internet. I didn’t test this out )


Some people have pointed me to these links.  They are more comprehensive!

How have you lived?

May 28, 2007 2 comments

Today, I had a lunch with an old friend.  We had an interesting conversation, and we touched on how a colleague of hers turned health conscious and became a vegan.  She also paid to go on health camps and detoxifying exercises.  Her supervisor was a bit stumped on her willingness to pay good money for such activities.  His comment was “Everybody dies eventually.”

That got me thinking.  It is a fact that everybody dies eventually.  The difference is, how did you live?

Did you live just like everyone else, so that your dying was nothing, well, spectacular?  Just another person that passed on?  A shadow that slide across a dark alley?  The candle that never burned bright enough to light the room?

Will you live a boring life, or did you do something interesting?  Did you live just to earn today’s meal, or did you do something that you’re passionate about?  Did you live a life with integrity, honesty, honor, joy, happiness, care and love?  Or did you lived like the walking dead?

In the end, the difference is in the living.  You would have lived so that no one would want you to die.  Tall order?  How about, you would have lived, so that someone remembered that you died?

Categories: Chatter, Filosophical

Chinese toothpaste found to contain a potentially deadly chemical

May 23, 2007 Leave a comment

I read this news article about how a toothpaste made by a Chinese company contained diethylene glycol, which could be blamed for causing 51 deaths in Panama after mixing with cough syrup.


Chen Yaozu, general manager of Danyang Chengshi Household Chemical Co., said his company had exported toothpaste to Panama containing diethylene glycol, a chemical blamed for the deaths of at least 51 people in the Central American country last year after it was mixed into cough syrup.

In the article, you can read “used as a low-cost substitute”, “permitted under Chinese rules and was safe in small amounts” and “export markets worth about US$30 billion (€22.2 billion) on alert”.

It is disturbing for a few points. Obviously a lot of manufacturers are using low-cost chemicals to manufacture low-cost products for the masses for the purpose of profits. The safety of chemicals that is acceptable is also questionable. In this instance, it was not safe for 51 people. The most disturbing point was that concerns are more focused on economic ramifications , and not humane concerns.

When are we going to wake up to the facts that the authorities’, the governments’ and the manufacturers’ primary concern is about the bottom line? When are we going to start taking responsibilities on deciding what goes into our mouths and on to our skin?

Read the full news article here.

Categories: Chatter, Filosophical, Health

Gaim is now Pidgin

May 22, 2007 Leave a comment

As I was grappling with some font problems (looks normal size on my screen, but looks huge on my friends’ Yahoo Messengers) with Gaim, I decided to check for latest updates as I found out that my Ubuntu 6.10 packaged Gaim version was a Beta one.

Lo behold!  Gaim has been renamed to Pidgin!   It’s now officially version 2.0.0.

I have no idea when the name was changed.  I couldn’t find that information on its new web site.  But it’s interface looks a lot cleaner and nicer than the beta version that I was using.  Definitely getting classier.   The font size problem was fixed too.  Keep up the good work guys!

Ubuntu doesn’t package Pidgin yet, so you’ll probably have to download the source and compile it.  No big deal if you have all the necessary development libraries already installed…

Categories: Ubuntu 6.10

Too much See’s chocolates

May 18, 2007 1 comment

Arck…!  I was mildly hungry.  There was nothing to munch except some chocolates from See’s.  I took 3 pieces of them, and now I’m feeling like my stomach’s flipping over.  Too much sugar.  Arck, I’m sticking to dark chocolate from now on.

Categories: Chatter

Useful baking soda

May 17, 2007 2 comments

Wow, I didn’t know that there are so many uses to baking soda.  Such a humble cooking ingredient can be so useful.

It’s an effective remedy to heartburn, digestive distress, stomach upset and fatigue.  It’s an effective toothpaste.  It can be a soothing bath if you are suffering from sun burn.  It can draw out toxins from your skin if you are suffering from insect bites.

Read the full article here.

Lots of interesting articles here.

Categories: Health, Organic

CSS positioning of element within an element

May 10, 2007 1 comment

This drove me nuts for one day.  I was trying to overlay tables on each other, and appearing only when it’s relevant tab was clicked.  So the problem was with positioning.  The border encasing the table was mis-aligned against the list of tabs, and the table was extending beyond the border lines.

Just when I stumbled on this tutorial on the web, wife was “advising” me to take a break from work and sleep on time.

Well, after going through the tutorial this morning, I am glad to say that it worked!  You have to use “positioning: relative”, “positioning: absolute”, “clear: both” for the respective elements.  Go through the tutorial and you’ll see the light.

Thank you BarelyFitz!

Categories: css

Today’s rich kids

May 10, 2007 2 comments

This is what I saw today at a MacDonald’s during lunch time.

A teenage boy made an order at the counter.  As he was leaving with his order, he dropped his change of 3 10-cents coins.  Being aware of his dropping the coins, he kicked them closer to the wall of the counter, and walked away.  He didn’t bother to pick up his change.  The 30-cents was nothing to him.

It just shows how some kids do not appreciate the value of money, nor how hard their parents have to work to earn the money.  It also shows how some parents are not educating their kids the right things in life.  Maybe one day he will learn the hard way.

So what happened to the 30-cents?  I picked them up after my meal, and put them into the Ronald MacDonald’s Children Charity box.  There are some kids who can benefit from them.