ruby on rails - NoMethodError: undefined method `add_a_file' for Testmethod:Class -


What is the reason for this error? It does not matter that self is specified.

  Class Testmethod & lt; ApplicationController def add_a_file (files, next 1, f) true end next1 = 0 files = Array.new Dir.chdir ("db / testdir") Dir ["*. Xls *"] Every do F | Self.add_a_file (Files, Next 1, f) # Error thrown here. Next 1 + = 1 end Dir ["* .csv *"]. Do each. F | Self.add_a_file (files, next 1, f) next 1 + = 1 end sfiles = files.sort {| First, second. First [1] & lt; = & Gt; Second [1]} # finishes sfiles.inspect by MDT by ASC  

Instead of an example, call the add_a_file method Testmethod class ( Testmethod.add_a_file ), or you should make an example of this class:

  example = self.new  

or add_a_file a single method (class method):

  def self.add_a_file (files, next 1, f) true end  

Comments

Popular posts from this blog

Member with no value in F# -

java - Joda Time Interval Not returning what I expect -

c# - Showing a SelectedItem's Property -