Showing posts with label Ruby. Show all posts
Showing posts with label Ruby. Show all posts

Monday, April 29, 2013

DB2 Rails rake test:units


When I try to run rake test:units I got error.

rake aborted!
Task not supported by 'ibm_db'
....

Tasks: TOP => db:test:load => db:test:purge
(See full trace by running task with --trace)

So the ibm_db plugin didn't provide db:test:purge task.

I found there is a project http://rubyforge.org/projects/db2extended/
But it looks like not work with Rails 3. So I just copy the db2extended_tasks.rake into lib/tasks. It seems works. 

Saturday, June 16, 2012

rvm mongrel init.d non-root

  I need init.d script to start my mongrel cluster , because my machine always reboot with no reason by hosting company.
Here is what I do in 3 steps:

1. Create a wrapper - https://rvm.io/integration/init-d/
    rvm wrapper ruby-1.8.7-p334 bootup mongrel_rails
    rvm wrapper ruby-1.8.7-p334 bootup starling


2. Create /etc/init.d/mongrel
#!/usr/bin/env ruby
#
# mongrel Startup script for Mongrel by Tim Morgan, modifyed by Eric
#
# chkconfig: - 85 15
# description: mongrel manages Mongrel
#


apps = [
  {:app => 'eric', :cluster_config_path => '/home/u/apps/eric/current/config/mongrel_cluster.yml'} ]
default_port = 9300
default_options ={
  :app_dir => '/home/u/apps/eric/current',
  :enviroment => 'production'
}


if ['start','restart','stop', 'status'].include? ARGV.first
  apps.each do |app|
    options = default_options.merge(app)
    puts "#{ARGV.first}:  #{options[:app]} using #{options[:cluster_config_path]}..."
    puts `su eric -c 'bootup_mongrel_rails cluster::#{ARGV.first}  -v  -C #{options[:cluster_config_path]}' `
  end
end


if ['start'].include? ARGV.first
    puts `su eric -c 'bootup_starling -d -P /home/u/apps/pfs/current/tmp/pids/starling.pid -q /home/u/apps/pfs/current/starling'`
end


unless ['start','stop','restart','status'].include? ARGV.first
  puts "Usage: service mongrel {start|stop|restart|status}"
  exit
end


3. Add into runlevel by chkconfig
     chkconfig --add mongrel
     chkconfig --level 3 mongrel on

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.

Thursday, September 16, 2010

jruby-rack error

After I deploy the war file created from warble to tomcat-5.5.27.
It gave me this error:
org.jruby.rack.RackInitializationException: java.lang.NoSuchMethodError: javax.servlet.ServletContext.getContextPath()Ljava/lang/String;

Goggling, someone sugguest downgrade to jruby-rack to 0.9.6.
But I can't install this version, it complain they can't find it.

Then I try to deploy to tomcat 6.0.29, it looks fine now. :)
It turn out the ServletContext.getContextPath() is in servlet 2.5 spec, tmcat-5.5 just servlet 2.4.

Reference:

Friday, March 26, 2010

options_for_select

I have two-element-array [["Credit Card","1",["Cash","2"] serves as options for a drop down box.

After post and error back to redisplay the page, the selected value didn't work. I know we need set the pre-selected value somewhere. But I really have no idea.

I am finally find this blog and know the answer is options_for_select helper.

Wednesday, October 14, 2009

Where is Null pointer?

I have a Null Pointer
I check all my variable at my code
I can't find a possible Null pointer
I know It come from ExternalMessage Class

It said like below
msg = new ExternalMessage();
msg.sendMessage(sender,receiver,subject,content)

Finally I got the idea
This sendMessage have addMessage method call inside.

The problem is the Exception wrapper
It hide the real problem

Friday, May 15, 2009

Rake on Ubuntu

I try to install the spree, when I try to do "rake db:bootstrap", it gave me error like this,

rake aborted!
undefined method `reenable' for [environment]>:Rake::Task


It turn out I install Ubuntu's rake, after I uninstall the rake of ubuntu, it work fine.