English 中文(简体)
积极记录物体的铁路Xml
原标题:rails xml to active record object

我在试图将XML申请转换成一个活跃的纪录标语时ling。 我利用“积极观察”方法,从“xml”方法尝试过,但似乎没有处理关系。

例如,我要说的是:

<blog>
  <title></title>
  <blog-pages>
    <blog-page>
      <page-number></page-number>
      <content></content>
    </blog-page>
  </blog-pages>
</blog>

我有以下示范目标:

class Blog < ActiveRecord::Base
    has_many :blog_pages

end

class BlogPage < ActiveRecord::Base
    belongs_to :blog

end

是否有办法将xml转换成与关系有关的博客物体? 或者,我是否需要人工地将XML混为一谈?

提前感谢。

问题回答

我禁止我一边这样做。 似乎没有用人工方式绘制XML的地图,用于活性记录物体。 虽然我的需求与你的需求相似,但我还需要做很多工作,不要仅仅反对关系。 我看着很多地方,找不到任何东西。 我决定自己解决该问题,但认识到,那只是一个线人,这样就写了一条扩大积极共识的格言。 我以韦恩· Robinson的工作为基础:

rel=“nofollow” http://www.wayne-robinson.com/journal/2006/5/1/ruby-on-rails-activerecordbuild_ from_xml-Function.html

在我没有生存的剩余时间过了几个月之后,我完成了我的灰.,你可以在RubyGems检查:

Hope this helps :) Cheers,

Michael M.

附录

xml_active现已正式退休,发展现在侧重于数据_活性(见) 其功能是xml_active,但在今后释放时,我将努力支持其他格式。





相关问题
rails collection_select vs. select

collection_select and select Rails helpers: Which one should I use? I can t see a difference in both ways. Both helpers take a collection and generates options tags inside a select tag. Is there a ...

SSL slowness in EC2

We ve deployed our rails app to EC2. In our setup, we have two proxies on small instances behind round-robin DNS. These run nginx load balancers for a dynamically growing and shrinking farm of web ...

Auth-code with A-Za-z0-9 to use in an URL parameter

As part of a web application I need an auth-code to pass as a URL parameter. I am currently using (in Rails) : Digest::SHA1.hexdigest((object_id + rand(255)).to_s) Which provides long strings like : ...

RubyCAS-Client question: Rails

I ve installed RubyCAS-Client version 2.1.0 as a plugin within a rails app. It s working, but I d like to remove the ?ticket= in the url. Is this possible?

activerecord has_many :through find with one sql call

I have a these 3 models: class User < ActiveRecord::Base has_many :permissions, :dependent => :destroy has_many :roles, :through => :permissions end class Permission < ActiveRecord::...

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

Text Editor for Ruby-on-Rails

guys which text editor is good for Rubyonrails? i m using Windows and i was using E-Texteditor but its not free n its expired now can anyone plese tell me any free texteditor? n which one is best an ...

How to get SQL queries for each user where env is production

I’m developing an application dedicated to generate statistical reports, I would like that user after saving their stat report they save sql queries too. To do that I wrote the following module: ...

热门标签