Ruby on rails Activeresource,更新和合并

Ruby on rails Activeresource,更新和合并,ruby-on-rails,ruby,ruby-on-rails-3,activerecord,activeresource,Ruby On Rails,Ruby,Ruby On Rails 3,Activerecord,Activeresource,我遇到了一个问题,我现在无法处理ActiveResource对象,该对象的外观如下: #<Settings:0x000000085fff48 @attributes= {"account_id"=>1, "created_at"=>"2012-01-10T14:54:36Z", "id"=>1, "settings_hash"=> #<Settings::SettingsHash:0x000000085ff250 @a

我遇到了一个问题,我现在无法处理ActiveResource对象,该对象的外观如下:

#<Settings:0x000000085fff48
 @attributes=
  {"account_id"=>1,
   "created_at"=>"2012-01-10T14:54:36Z",
   "id"=>1,
   "settings_hash"=>
    #<Settings::SettingsHash:0x000000085ff250
     @attributes=
      {"email_notices"=>
        #<Settings::SettingsHash::EmailNotices:0x0000000860c860
         @attributes=
          {"none"=>
            ["none", "none"]},
         @persisted=false,
         @prefix_options={}>,
       "permissions"=>
        #<Settings::SettingsHash::Permissions:0x0000000860c1d0
         @attributes=
          {"default"=> [["all"], ["all"] ]},
         @persisted=false,
         @prefix_options={}>},
     @persisted=false,
     @prefix_options={}>,
   "field_key"=>"BRp7Box33sg",
   "fieldone"=>1,
   "updated_at"=>"2012-01-10T14:54:36Z"},
 @persisted=true,
 @prefix_options={}>
我很难回到对象中,然后我想更新回它的来源

所以,我正在做一些我现在还不太了解的事情,也许是以一种尴尬的方式。建议


我想在ActiveResource对象内的哈希字段中添加一个哈希,以更新其他位置的ActiveRecord对象实例,但目前无法完全更新。

您应该能够访问活动资源对象,就像访问活动记录模型一样:object.settingshash.attributes['key']=['value'],然后通过object.save保存该对象。如果这不起作用,请尝试保存您正在修改的对象object.settingshash.saveWorking我得到的哈希值是一个“HashWithInferenceAccess”,现在使用它并不直观。我将使用它,但在某种程度上,我正在寻找一个更大问题的解决方案:一种更好的方法来管理散列字段中的一组设置,该散列字段被拉到远离其源数据库的基于Activeresource的应用程序中。这是可行的,但散列字段似乎会打乱Activeresource,从而导致“堆栈级别太深错误”“更新_属性”也很困难,尝试设置任何内容(例如,添加到哈希中的哈希)也会导致错误。此时,我可以添加到我所在的模型中,只需保存或更新它所在的模型。
thisobject.settings_hash['permissions'].attributes.merge({"derp"=>[['dsfasdf'],['asdfasdfadsf']]})