Saturday, May 28, 2011

Convert string to a class/model

This post is related to how to convert string to class ( model ). I came across this situation while migrating one of my organization's project on rails 3.

Many times we came across a situation where we need to convert a string to respective class or model. So that we can call methods on it. Generally to handle this situation new rails developers use case statement like this,

case class_name_string
when 'Account'
object = Account.find(id)

when 'Contact'
object = Contact.find(id)

when 'Opportunity'
object = Opportunity.find(id)

when 'Campaign'
object = Campaign.find(id)

when 'Model1'
object = Model1.find(id)

when 'Model2'
object = Model2.find(id)
when 'Modeln'
object = Modeln.find(id]) 

This can be actually done pretty easily by using constantize in only one line


Sunday, May 22, 2011

Touch pad is not working on Ubuntu 11.04

Following is blog post with respect to the problem which I faced on my dell xps laptop with Ubuntu 11.04. My mouse pad(Touch pad) was not working after login screen.

After some googling I found forum articles which describing same problem. Those peoples have different version of Ubuntu with different manufactures of laptop.

But I didn't found an exact cause of this issue. One of the person from the forum was saying, this is might be due to use of mobile broadband network.

Might be this is the cause because, I am also using mobile broadband on my laptop where issue is occurring. But at the same time in my company I am using Ubuntu 11.04 on my development machine with wired Internet but I never faced this issue.

Anyways following is the solution,
Execute following command on terminal

gconftool-2 --set --type boolean /desktop/gnome/peripherals/touchpad/touchpad_enabled true