ruby on rails - Can't call class method within another class -


i have 2 classes found within lib folder. both files found in lib/services folder. i'm loading files via method in initializer.

['account_helpers', 'facades', 'decorators', 'presenters', 'serializers', 'services', 'views', 'queries'].each |folder|   dir["#{rails.root}/lib/#{folder}/*.rb"].each {|file| load file} end 

my 2 classes appear so...

class marketingemail   def self.send     user.where('created_at >= ?', 15.days.ago).each |user|       marketingemaildecider(user).deliver     end   end end  class marketingemaildecider < marketingemail   def init(user)     @user = user   end    def deliver     puts "delivered"   end end 

whenever run code following error

 nomethoderror:    undefined method `marketingemaildecider' marketingemail:class 

why happening , how can fix this? i'm having no other issues running other classes in of other classes (if makes sense).

problem not calling constant marketingemaildecider, youa re trying execute method: marketingemaildecider(user). believe wanted: marketingemaildecider.new(user).deliver.

btw, initialize in ruby, not init.


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -