On Tuesday 12 May 2009, 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
I hope you know what you're doing. What if one of the strings is
%x{echo gotcha}
or worse?
> 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.
Then move it down to the bottom, or if you want to hide it even more,
put it in a module:
class MyModel < ActiveRecord::Base
include ComplicatedStuff
...
end
> And if so, will it work out of the box or do I need to add a
> "require" somewhere or alter any configuration files.
As long as it is in one of the "usual" directories, i.e. app/models,
lib, the module will be found automatically.
Michael
--
Michael Schuerig
mailto:[email protected]
http://www.schuerig.de/michael/
--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---