More YAML and rake nonsense

My attempts at building custom rake tasks to pre-load initial data for applications continues, and is another widely reported problem.

I have two models, User and Role both in my app/models directory as you’d expect. I do all standard stuff to set up the environment in rake, there are no structural differences at all in the code.

The rake task use users works fine but for roles I get,

rake aborted!
ArgumentError: undefined class/module Role
../lib/taksks/post_migrate_roles.rake:6:in `block (2 levels) in <top (required)>'
Tasks: TOP => db:task_prep_roles
(See full trace by running task with --trace)

Indicating a potential problem with the YAML file; the only difference being the user yml has,

---
- !ruby/object:User
  attributes:
   id: 1

and the roles.yml has

---
- !ruby/object:Role
  attributes:
   id: 1

There might be something problems with serialised object at http://alisdair.mcdiarmid.org/2013/02/02/fixing-rails-auto-loading-for-serialized-objects.html but it’s quite deep and I’m including it here as a reminder to check out later.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s