occasionally useful ruby, ubuntu, etc

30Mar/080

jQuery :(

I wish Rails wasn't so intimately tied with Prototype+scriptaculous. It makes jQuery that much harder to use. Even so, using page << and jQuery is much easier than trying to use Prototype to achieve the same end. Not to be a fanboy or anything, but is there any other library out there that can remove a specific option from a dropdown select box in one short line of code?

25Mar/080

Dynamic Methods in Ruby

So this was sort of hard even if it doesn't look like it, but I found out how to do dynamic methods and whatnot. Put this in your class.

def self.my_method(takes, two)
	define_method "cool_"+takes do |arg|
		puts two + arg
	end
end
Filed under: ruby Continue reading
24Mar/082

Simple Easy AJAX Form Validation in Rails

I'm using Ruby 1.8 and Rails 2 for this.

Thanks to BigSmoke for both the ActiveResource::Errors hint as well as inspiring me to look for another way.

What this method does is create and populate an error div with the specific error messages that occurred, and then destroy the div when the user submits a valid entry.