Sunday, April 29, 2012

Error: uninitialized constant MysqlCompat::MysqlRes

After upgrade to Ubuntu 12.04, my rails application show this error. It turn out the upgrade did upgrade mysql to version 5.5 , then we need rebuild the mysql gem. Just uninstall the mysql gem then install it again.

Saturday, June 4, 2011

Apache 2 SSL Name-Based Virtual Hosting

My work need to work on many clients at the same time. And they all use https. I need create development environment. Finally I found this "How To" http://fob.po8.org/node/289
And It work for me.

Friday, December 31, 2010

mongrel and rails3

Trying to use rails3 with mongrel. It got error out.
Find this post: http://jan.varwig.org/archive/rails-3-and-mongrel

Put those lines into Gemfile
gem “mongrel”, “1.2.0.pre2″
gem “cgi_multipart_eof_fix”
gem “fastthread”

But using "mongrel_rails start" still not working.

It's fine when using "rails server" to start the mongrel_rails.

Thursday, December 30, 2010

gem install mysql2 fails.

It turn out need this package 'libmysqlclient-dev'.
Under Ubuntu 10.04 , 'sudo apt-get install libmysqlclient-dev'.

Wednesday, October 6, 2010

Know the different PATH_INFO

My rails application have root route to a store controller.
I need to know the user request sample.com or sample.com/store/local/12342 so I could show different text on the html title.
It could be done by using request.env["PATH_INFO"] to get the data.
If it is just plain sample.com it will return nil.

Clone Xen VM

I have been created an Xen VM. I want to clone it.
My enviroment is centos 5.4 with Dom0 installed.
And the original template vm is centos,too.
1. lvcreate -L 10G volGroup00 -n vm1
2. virt-clone --original vm_template --name vm1 --file /dev/VolGroup00/vm1 --force
3. edit /etc/sysconfig/network's hostname.
4. change ip if you don't want use dhcp.

Thursday, September 23, 2010

Legacy System Refactoring - 1. Middle Tier Data Acess

The Legacy System I work on is lots of JSP pages with POJO classes application. The business logic all spread on JSP pages and the POJO classes, thought it is east to start but it is hard to maintain. And the starter not me, I am the maintainer. Everytime I got new requirement, I feel not like to work on it. It took time to understand all the related , even unrelated topic , so that I could work on.

First step, I think adopt Middle Tier Data Access using JdbcTemplate should be easy way.

JdbcTemplate

Let me work on the products table.

1. Domain -- create Product domain class with get/setter methods.

2. DAO -- create ProductDao interface with CRUD methods.

3. JDBC DAO implementation -- public class JdbcProductDao extends SimpleJdbcDaoSupport implements ProductDao

4. ProductManager -- create ProductManager interface so you could group the product related methods together.

5. SimpleProductManager -- implementation of ProductManager interface.

6. Config applicationContext.xml -- specify dataSource, productDao, productManager bean.

7. Jsp pages get the productManager bean --
WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(application);
ProductManager productManager = (ProductManager)ctx.getBean("productManager");

That's it. only 7 steps to Refactory that.