Rhomobile-加载\u脱机\u数据问题

Rhomobile-加载\u脱机\u数据问题,rhomobile,Rhomobile,当用于从.txt文件加载种子数据时,我面临加载\u脱机\u数据的问题 我的代码如下所示: > def initialize > Rho::RHO.load_all_sources() > products = Product.find(:all) > Rho::RhoUtils.load_offline_data(['products'], 'db') end 在db/fixtures/products.txt中 source_name|at

当用于从.txt文件加载种子数据时,我面临加载\u脱机\u数据的问题

我的代码如下所示:

> def initialize
>     Rho::RHO.load_all_sources()
>     products = Product.find(:all)
>     Rho::RhoUtils.load_offline_data(['products'], 'db')   end
在db/fixtures/products.txt中

source_name|attrib|object|value
Product|name|1|product 1| Product|order_id|1|1|

Product|name|2|product 2|
Product|order_id|2|2|
我得到的错误如下:

> def initialize
>     Rho::RHO.load_all_sources()
>     products = Product.find(:all)
>     Rho::RhoUtils.load_offline_data(['products'], 'db')   end
应用程序初始化失败:nil的#source_id:NilClass>;Trace:lib/rho/rhoutils.rb:71:load\u offline\u data'中的inblock(3级)

有人能帮我吗


提前谢谢

Sri,我必须手动要求“rho/rhoutils”

为了避免源代码id错误,我必须调用Rhom::Rhom.database\u full\u reset(true,true)。由于这将在每次初始化应用程序时重置数据库,因此我包含了一个保护程序,用于检查我的trees表是否已填充

require 'rho/rhoapplication'
require 'rho/rhoutils'

class AppApplication < Rho::RhoApplication
  def initialize
    # Tab items are loaded left->right, @tabs[0] is leftmost tab in the tab-bar
    # Super must be called *after* settings @tabs!
    @tabs = nil
    #To remove default toolbar uncomment next line:
    #@@toolbar = nil
    super

    if Tree.find_all.empty?
      Rhom::Rhom.database_full_reset(true, true)
      Rho::RhoUtils.load_offline_data(['object_values'], '')
    else
      puts "*"*80
      puts "ALL GOOD"*5
      puts "*"*80
    end

    # Uncomment to set sync notification callback to /app/Settings/sync_notify.
    # SyncEngine::set_objectnotify_url("/app/Settings/sync_notify")
    # SyncEngine.set_notification(-1, "/app/Settings/sync_notify", '')
  end
end
要求“rho/rho应用程序”
需要“rho/rhoutils”
类AppApplication右,@tabs[0]是选项卡栏中最左边的选项卡
#Super必须在*settings@tabs之后调用*after*settings!
@制表符=零
#要删除默认工具栏,请取消注释下一行:
#@@工具栏=零
超级的
如果Tree.find_all.empty?
Rhom::Rhom.database_full_reset(true,true)
Rho::RhoUtils.load_offline_数据(['object_values'],'')
其他的
放置“*”*80
将“一切都好”*5
放置“*”*80
结束
#取消注释以将同步通知回调设置为/app/Settings/sync\u notify。
#SyncEngine::set_objectnotify_url(“/app/Settings/sync_notify”)
#SyncEngine.set_通知(-1,“/app/Settings/sync_notify”,”)
结束
结束