Fonctions communes dans les rails
# lib/my_utilities.rb
module MyUtilities
def trim_string(string)
do_something
end
end
#Then in controller or model where you want this:
# models/foo.rb
require 'my_utilities'
class Foo < ActiveRecord::Base
include MyUtilities
def foo(a_string)
trim_string(a_string)
do_more_stuff
end
end
Testy Termite