What is it for?

Rather than storing a list of things in the database as strings, e.g. Mr, Mrs and so on, instead we store an integer value that we can look up to get the true value. This is done for a number of reasons, e.g. it is easy to change the meaning of a code without having to update large tables, storing an integer is a lot less space than a string and so on. It is also easy to translate a site if needed, but this plugin is’t sophisticated enough to do that.

It does have some disadvantages in that you need to know what the magic number means and it can make writing queries a pain. The plugin has methods that will help with this.

I have put this into a git repository http://github.com/fjfish/has_lookup_extension/tree/master, the git pull url is

git://github.com/fjfish/has_lookup_extension.git

I can’t work out how to make the script/plugin install command work with it and have’t got time right now.

To install call the repository down into vendor/plugins/has_lookup_extension in your rails app.

Go to the root of the rails app and type in

ruby vendor/plugins/has_lookup_extension/install.rb

run the migration. The documentation is’t extensive but should be enough, I hope.

If anyone wants to get it installing using the proper rails command, or tell me how to get it doing so, gimme a shout, or I can add you as a collaborator.

Have fun