Rails + runner limited to one model?

Hi,

I am trying to run a batch job on demand and using the script/runner
command.
The job will add some informations in the database with dependencies.

So I have the following code but it failed.

=============
Class Father < ActiveRecord::Base
has_one :son

Class Son < ActiveRecord::Base
belongs_to :father

self.update_son
father = Father.new
…(some code)
son = Son.new
father.son = son
son.name = “Tom”
son.gender = “Male”
…(some code)

ruby script/runner -e development “Father.update_son”

The error is on the line “son = Son.new”.
The output is telling me “uninitialized constant Father::Son
(NameError)”.

I was asking me if you can only access to the model used in the command
line with runner ?

Or perhaps I am missing something else (about the use of relationship
with rails).

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs