Is there anyway to create a function I can call both in the model and controller? I have a function that grabs an array of files and strips the extension off and want to validate against the list. However I also want access to this list in the controller so I can output a select box for the options. I currently have this, however the VALID\_MODULES doesnt get populated all the time. 

```
class Job < ActiveRecord::Base

  after_initialize :init
  VALID_MODULES =[];

  validates :name, presence: true
  validates :desc, presence: true
  validates :api, presence: true, :inclusion => { :in => VALID_MODULES}
  validates :filters, presence: true
  validates :toe, presence: true

  def init
    Dir.foreach('lib/resources') do |item|
         next if item == '.' or item == '..' or item == 'resource.rb'
            #Wont be called very often so O(n) complexity is fine (small #elements)
            VALID_MODULES.push(item[0..-4]) unless VALID_MODULES.include?(item[0..-4])
    end
  end

end

```