My background in C++ and Java has instilled in me some programming habits that don’t play nice in Ruby. When I want to increment or decrement a number, my fingers instinctively go to ‘++’ and ‘–’’.
Unfortunately, this syntax is not supported by Ruby. As a language design choice, Ruby opted to not support this syntactic sugar to increment/decrement a variable.
I will have to break my habit and start going with:
// increment x
x+=1
// decrement x
x-=1
Another thing to note is that the prefix increment/decrement operators like ‘–x’ or ‘++x’ do nothing. The signs are interpreted as unary operators.
Posted in
geekery at March 15th, 2008.
View Comments.
I’ve been trying out the newly released Rails 2.0. Lots of cool new stuff. However, it takes some time to get used to doing things the new way if you haven’t been working from EdgeRails.
One of the features that came out of the box in previous releases was support for autocomplete using scriptaculous. This has now been moved from the core rails install to an install via plugin.
Just install the plugin via:
script/plugin install http://svn.rubyonrails.org/rails/plugins/auto_complete
Then, you have to turn off the cross-site request forgery protection that comes with Rails 2.0.
You can do this at the Controller level by adding something similar to the following:
class UsersController < ApplicationController
protect_from_forgery
nly => [:update, :delete, :create] // exclude the auto_complete method
...
end
If you don’t do this, your autocomplete actions will throw an ActionController::InvalidAuthenticityToken exception which caused me hours of confusion.
Posted in Uncategorized at December 11th, 2007.
View Comments.
After fighting apache for a couple hours, I finally have mongrel set up to proxy through apache.
At first I had the proxy module enabled but was getting a 403 page. After adding logging to the vhost config, I see
[Mon Sep 10 22:57:00 2007] [warn] proxy: No protocol handler was valid for the URL /. If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration using LoadModule.
I go ahead and find out I didn’t have proxy_http enabled. After executing sudo a2enmod proxy_http and bouncing apache, TA-DA!
Posted in Uncategorized at September 10th, 2007.
View Comments.
I have been trying to get a rails app served up by a mongrel cluster through apache. All the documentation I’ve looked at says this can be done with an Apache module mod_proxy_balancer. Looks like my apache install using apt-get does not come with that module. Blah! Guess I have to pull down the source and build from source. Hopefully, I don’t break anything!
References:
Posted in Uncategorized at August 19th, 2007.
View Comments.
It was easier than I thought it would be to install Java and Tomcat. With a few apt-get commands, I had both Java and Tomcat up and running. The next step was to serve Tomcat through Apache. This was done by using the AJP Connector. Tomcat is running with AJP connector port 8009 and I can serve up JSPs and servlet content through Apache who is listening on port 80. Pretty slick
It was even easier to get a Rails app up and running on WEBrick on default port 3000.
Next steps will be to serve Rails content through Apache.
Posted in Uncategorized at August 19th, 2007.
View Comments.