Reputation: 65877
I have couple of helper methods added to the existing classes, and i want them to be loaded only once. for example i have a except method
class Array
def except(array)
self.select do |item|
array.exclude? item
end
end
end
and would like to call it from different views & controllers like this
a= [1,2,3,4]
b=a.except [1,3]
Upvotes: 0
Views: 146
Reputation: 2479
Put it into a file in config/initializers. These are loaded in alphabetic order; so if some other code uses it during initialisation, just use a file like config/initializers/000_important_monkey_patches.rb
Upvotes: 1