Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problem with file location when using Fixtures.loadModels("...")

I'm using the Play Framework yabe tutorial and came across a problem when adding tags. I'm not sure what code I added that caused the change, but now the Fixtures.loadModels(data.yml) piece of code searches for a file in .../some_folder/play-1.2.1/modules/docviewer/app/data.yml instead of .../some_folder/yabe_tutorial/conf/data.yml as it should.

Here's my code in the default package of /yabe_tutorial/app:

@OnApplicationStart
public class Bootstrap extends Job { 
  public void doJob() {
    if (User.count() == 0) {
        Fixtures.delete();
        Fixtures.loadModels("data.yml");
    }
  } 
}

Is there any settings I can use to change the directory that loadModels uses?

I'm new to this all, so I'd really appreciate some help. Thanks!

like image 609
drewse Avatar asked Jun 08 '11 03:06

drewse


1 Answers

Sigurd is right. Fixtures.loadModels() looks for the yml file in Play.javaPath. Try renaming your data.yml file to some unique name like data-appname.yml and change the filename in your code as well.

@OnApplicationStart
public class Bootstrap extends Job { 
  public void doJob() {
    if (User.count() == 0) {
        Fixtures.loadModels("data-appname.yml");
    }
  } 
}

Worked for me.

Another option is to use Play.applicationPath which contains the location of root directory of the project

Fixtures.loadModels(Play.applicationPath + "/app/conf/data-appname.yml");
like image 144
manish_s Avatar answered Oct 31 '22 17:10

manish_s