Where to put additional code for model.

Jim Burgess wrote:

Hi, I have written a method to map three 'virtual' fields in my form to one 'proper' field in my model. It looks like this:

class Class   def map_three_fields(var1, var2, var3)     string_val = "...do stuff..."    self.class_eval string_val   end end

At the moment it is sitting at the top of my model, but the method is quite long and this looks a bit ugly / cluttered.

Is there anywhere else I can put this code?

In my opinion (backed by zero experience), models are serfs, and controllers are the aristocrats that command the serfs to do various chores. So if you think a controller is going to get its hands dirty doing the work of a serf, well...you better think again.

Of course you could create another model--one not hooked up to a database--that has a class method that you could call like this:

Utilities.map_three_fields()

And no, you wouldn't need a require.