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. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---