Ruby on Rails: custom fields on a per-user basis

I’m now developing a flexible car database for a couple of hours per week. Our first customer, a Beemer dealer, has a lot of fancy requests. Well, the hired-in Flash developer has these requests actually.

One of them is that they want to save a field in the database that contains a unique identification number for the secondhand cars they sell. But this number is set-up in a way that is unique to BMW’s. So actually, I didn’t want to add this column to the database, ’cause that will mess up my clean database tables.

But then I came up with the idea to add functionality to the website where users (dealers in this case) can add custom columns to their cars / profiles.

Instead of creating this functionality from scratch, I first wanted to know if there are any plugins that have this functionality already. I found these three:

  1. acts_as_free_form
  2. has-magic-columns
  3. acts_as_customizable

I haven’t decided (yet) which is best.

And if you want to roll your own, here’s a nice article about choosing the best structure for dynamic fields.

I realize that the story above is written in truly horrible English. But I really didn’t have the energy to make something nice of it…

4 comments ↓

#1 Ryan on 09.23.09 at 20:45

Thanks for the post. Which method did you end up choosing? How did it work out for you?

#2 LeonB on 09.23.09 at 21:17

I forked has_magic_columns and and I’ve used it on the “auto” model.

#3 Anu on 05.05.10 at 13:58

Hi Leon,

Could you please explain the usage of has_magic_columns :for => and has_magic_columns :through => ?
Also how can i remove the magic columns?

Thanks,

#4 Daniel on 12.15.10 at 12:35

Hi, how did you deal with the view? I mean, how to dynamic add the fields and reutilize them other time associating like a nested form.

I don’t know if I made myself clear.

Thanks

Leave a Comment