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 = ActiveRecord::Base.connection.tables.map{|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.

How to get what you want

An email from the great Campaign Montior landed in my inbox today and contained a link to a helpful article about getting information on why users have unsubscribed from your email campaign.

This is such a simple concept but it seems that so many seem to be unaware of it. I've recommended this same technique to others in regard to just about anything: if you want something, ask for it.

Many not-for-profit organizations understand this, others seem to miss it. Certainly the way that you ask will have an affect on the answers, but not asking is a great way to not get what you want.

  • Before you leave an interview ask for the job.
  • Ask someone specifically to volunteer for your event.
  • Get a great developer on your open-source project by asking.
  • Need funding for an expansion to your school/university/community center/whatever? Ask for it.

People respond to questions, and asking them with a certain approach will help you get your answer. Take a listen to some great advice for managers on how to delegate tasks (it involves asking for help).

Asking for what you need directly affects your future. By not asking, it means you're just waiting for your future to happen to you.

Radiant Comments and Spam

I've been working with the Radiant Comments extension trying to pull in the various changes from the community and just planning to clean things up in general.

Rather than dealing with an outside service for spam filtering, I'm working on the idea of a simple question to block spam. The comment form asks a simple question that a spambot might not know. It may require more work, but some users of Radiant may find things difficult enough without needing to go to Akismet or Mollom for spam filtering. Yes, I know that's a simple task, but for some just the idea of yet another thing to do gives them pause.

So with this post, here's my test of the spam_answer_tag. It's easy to use: you simply add

What color is a stop sign? < r:spam_answer_tag answer="red" />

I'll certainly be doing more work on the extension to clean things up, but I felt that it needed at least a simple CAPTCHA type of option built-in without all the downsides of generated imagery CAPTCHA.

Let me know what you think!

UPDATE: after reading Adam's comment about the number of questions I realized that you can easily provide your own list of options with Radius tags that are already a part of Radiant. Just use r:random and r:option.