Topic: method calling another method in same class fails...

I have been staring at the below code for 15 mins, I know it is something really obvious but for some reason the self.files_for class method cant call the private get_file_for method!?!

I know in this example I dont really need the private method but Im going to add files_for_views and files_for_layouts as seperate class methods which both call get_files_for...

The error is: undefined method `get_files_for' for View:Class

class View < ActiveRecord::Base
  has_many  :reports
 
  validates_presence_of :name
  validates_presence_of :view
  validates_presence_of :layout   
  validates_presence_of :category
 
  def full_name
    self.name + " [" + self.category.capitalize + "]"
  end
 
  def self.files_for(type)
    get_files_for(type)
  end
 
  private

  # List of all files for views or layouts
  def get_files_for(type)
    filenames = Dir.entries("#{RAILS_ROOT}/app/views/templates/#{type}").select do |filename|
      filename[0].chr != '.'
    end
    filenames
  end
end

Re: method calling another method in same class fails...

the get_files_for method needs to be a class method as well.. -> self.get_files_for(type)

  private

  # List of all files for views or layouts
  def self.get_files_for(type)
    filenames = Dir.entries("#{RAILS_ROOT}/app/views/templates/#{type}").select do |filename|
      filename[0].chr != '.'
    end
    filenames
  end
end

Re: method calling another method in same class fails...

Oh right, guess I should have tried that already! Thanks for pointing it out...