samedi 21 avril 2018

How to use rails api find_or_create_by in ruby?

I tried to run test a gem for rails. In the test, I am in ruby not rails. The purpose of this code is to create rails modules.

But this kind of codes will be a template supposed to run in rails. Problem come when test encountered something like

my_module= Myprogram::Module.find_or_create_by :module_code=>my_module.code, :code=> scode, :name=>sname

then

error: Undefined method find_or_create_by

My first though is to require (what) gem that has this method.

Can anyone help me out.?

Aucun commentaire:

Enregistrer un commentaire