Showing drop down list box for a field in RailsAdmin


RailsAdmin is really good if you want to create a out-of-the-box admin panel for your rails based application. It will generate a nice admin panel based on your models. Though, to me, it is not as intuitive as that of Django, it is very useful.

RailsAdmin can create several types of form fields like Text Fields, Text Area, Date Picker, Checkbox etc. based on your column’s type. However, sometime we may need to override it’s default behavior. For example, we may need to show a drop down list box for a field instead of text field.

Let’s assume we want to show a drop down list for status column of User model. So, open your user.rb from models directory and add the following method to the class definition.


def status_enum
   [['Active'],['Pending'],['Banned']]
end



Now you will see a list box for Status field when you go to Users section of Rails Admin. However,  if we can store different values in the database other than the strings shown in the list. Let’s modify our code to something like:
Continue reading →

Header Image Rotator for Twenty Ten theme of WordPress 3.0

WordPress 3.0 is still in RC1. I have already upgraded this blog to this version. I can’t but  simply love the new theme ‘Twenty Ten’ which is default in WordPress 3.0. It is super simple theme.

In this theme, there is option to use custom header image. From the admin panel you can select the header image. However, all of the default banners looked interesting to me and I have also uploaded some of my own shots. I wanted to show them all.

Keeping that in mind, I made this simple plugin, Twenty Ten Image Rotator. Having this plugin installed, you can show all images on the header. Single banner each selected randomly on each page load.

I believe if you love Twenty Ten theme, you will love this plugin too :).

Download from WordPress Plugin Repo