2010-05-12

Xapian on Rails

just cloned one of my work projects at home, executed script/server and BAM:
"acts_as_xapian: No Ruby bindings for Xapian installed"

I installed xapian and set this all up on my ubuntu laptop, now again to set it up on my desktop, so I figured I would document it here because I forgot what I did on my laptop.

Here goes the steps I took:
1 - Went to ubuntu package manager, searched for "xapian", installed "libxapian-ruby1.8"
2 - run "rake xapian:rebuild_index models="Article"

done :),
maybe this was too easy for a blog post. whatever

2010-05-10

my solution for rails ajax'd child-model form fields

I am mid-early development of a new interface for a web application. I can say that the interface will be making full use of as much ajax as is necessary and possible, and of course I'm using accepts_nested_attributes_for on the parent model. One problem I encountered early on was how to populate additional form fields using ajax.
The first solution I stumbled upon was the plugin ryan bates made to go along with Railscasts episode #196. This worked, but I needed something more flexible.

One of the obvious issues here is how to turn "model[childmodel_attributes][0][attribute]"(created by the form builder) into "model[childmodel_attributes][(random_number)][attribute]".
The solution is not in the documentation!

Try a random number!:
<% form_for @model do |f| %>
<% f.fields_for :childmodel, :child_index => (Time.now.usec + rand(1-999)) do |builder| %>

I use that code in my view to generate fields on a freshly built child model instance built from the rjs-calling controller.
using this method you have a more granular control over the content for the new record, a step above the model, in case you need such flexibility.

<% if builder.object.id.nil? %>
form fields here...

sorry I'm super tired, if this isn't clearly written, I don't doubt it. Actually I may make a video about my solution, because it's brilliant.

2010-05-02

ubuntu 10.04 install nvidia driver

Today I upgraded my laptop and desktop machines to Ubuntu 10.04 LTS. Best upgrade so far. No problems at all.

I'm posting this here for my future reference on how I installed the nvidia driver:

downloaded the driver 195.xxx from nvidia.com

drop to a terminal screen "ctrl + alt + f1"

Kill all instances of X and gdm, "service gdm stop"
and then I had to do "ps -e" to find the remaining X process and manually kill it by it's process ID.

"sudo kill xxxx"

Then edit this file as root:
"sudo nano /etc/modprobe.d/blacklist.conf"

Add these lines and save: (this part is very important, especially the nouveau part, that new driver really screws with the nvidia one)

blacklist vga16fb
blacklist nouveau
blacklist rivafb
blacklist nvidiafb
blacklist rivatv

then:
"sudo apt-get --purge remove nvidia-*"

"chmod 744 NVIDIA-Linux-x86_64-195.36.24-pkg2.run"

"sudo sh NVIDIA-Linux-x86_64-195.36.24-pkg2.run"

after a successful install either reboot or: "sudo service gdm start" or just "startx" if you dont need gdm running.