Register now and start sharing your code snippets.
-->
Fixing "warning: already initialized constant OPTIONS"
Shell Script (Bash) posted about 1 year ago by christian
If you’re using Edge Rails and mongrel you might have seen this error:
1 warning: already initialized constant OPTIONS
There’s a bug report here that explains this problem in detail.
The solution for me was to rerun the freeze command:
1 rake rails:freeze:edge
You might also get “warning: already initialized constant OPTIONS ” error if you haven’t installed a gem your software relies on. In the following example openssl should be installed:
1 /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require’: no such file to load—openssl (MissingSourceFile)
ActiveResource might also be the problem:
1 gem install activeresource --source http://gems.rubyonrails.org
Simple Mongrel HTTP server and custom Mongrel handler example
Ruby posted about 1 year ago by christian
1 # http://mongrel.rubyforge.org/rdoc/index.html 2 # gem install -y mongrel 3 require 'rubygems' 4 require 'mongrel' 5 6 # Usage: ruby mongrel_http_server.rb <host> <port> <docroot> 7 host = ARGV[0] || "127.0.0.1" 8 port = ARGV[1] || 80 9 docroot = ARGV[2] || "html/" 10 11 # Simple Mongrel handler that prints the current date and time 12 class HandlerExample < Mongrel::HttpHandler 13 def process(request, response) 14 response.start(200) do |head, out| 15 head["Content-Type"] = "text/html" 16 out.write Time.now 17 end 18 end 19 end 20 21 # Configure Mongrel and handlers 22 config = Mongrel::Configurator.new :host => host, :port => port do 23 listener do 24 uri "/", :handler => Mongrel::DirHandler.new(docroot) 25 uri "/handler_example", :handler => HandlerExample.new, :in_front => true 26 end 27 28 # CTRL+C to stop server 29 trap("INT") { stop } 30 run 31 end 32 33 # Start Mongrel 34 puts "Mongrel listening on '#{host}:#{port}', serving documents from '#{docroot}'." 35 config.join 36
Jump start a Rails project with Rails Edge, Capistrano, Mongrel and Mercurial
Shell Script (Bash) posted about 1 year ago by christian
1 # Create a Rails project 2 rails project -d sqlite3 3 cd project 4 # Delete index file 5 rm public/index.html 6 # Use Rails edge. Use rake rails:freeze:edge TAG=rel_1-2-3 to get a specific version. 7 rake rails:freeze:edge 8 # Add Capistrano configuration file 9 capify . 10 # Add Mongrel cluster configuration file 11 sudo mongrel_rails cluster::configure -e production \ 12 --user mongrel --group mongrel \ 13 -c /var/www/project-xxx/current \ 14 -a 127.0.0.1 \ 15 -p 8000 \ 16 -N 3 17 # Create a Mercurial repository 18 hg init 19 # Add project to repository 20 hg commit -A --message "Project started" 21 # Push changes to a remote repository 22 hg push ssh://user@ip:port//var/mercurial/xxx
Cloning is done with hg clone:
1 hg clone ssh://user@ip:port//var/mercurial/xxx