View, Edit and Search your RadiantCMS Database

I came across a handy plugin for Rails applications (version 2.2 or higher) that provides a simple way to view, edit and search the database. Read about it at Neeraj Singh's website.

I thought it would be a useful way to view data in radiant, so I quickly hacked together an extension to view the interface of admin_data.

Originally, the plugin was designed to look into your app/models directory and pull all the classes. But because Radiant loads classes from several locations, it was simpler to just alter this code:

model_dir = File.join(RAILS_ROOT,'app','models')
    Dir.chdir(model_dir) { models = Dir["**/*.rb"] }

to look at the database tables and assume you've followed Rails conventions and load class names according to the table names:

models ={|t| t.singularize.to_s }

The upside of doing that is that it will easily integrate into a system like Radiant.

In a quick test, I found that I also needed to provide a way to alter data in the database without calling validations, so I also provided just that: a button to "Save without Validation!"

At the moment, the extension documentation states that our fork is required and that may remain. The benefit of the original design is that admin_data just looks in the file system for the necessary information, and it preserves any non-standard table naming conventions defined in the models. The downside is that Radiant can't use it like that unless there is some configuration for where to load the models.

Both the extension and the plugin need more tests, but it looks to be a simple way to achieve a separate admin view of data without the need to write all the controllers and views.

I've added it to the extension registry so you can just do a script/extension install admin_data but you'll still need to install the plugin.