[redland-dev] ruby save

Eyal Oren eyal.oren at deri.org
Wed Sep 27 16:31:08 UTC 2006


On 09/27/06/09/06 02:02 -0700, Eric Hanson wrote:
>Hi,
>Forgive a total newbie question, but I'm trying to create triples and
>insert them into a repository using Dominic Sisneros' Ruby rdf-redland
>library, and am not sure how to do it.
>
>Its a eruby script.  My code is:
>
><%
>require 'rdf/redland.rb'
>require 'cgi'
>cgi = CGI.new
>
>store = Redland::HashStore.read_store('fook', '/usr/local/redland-data')
>model = Redland::Model.new(store)
>
>res = model.create_resource(cgi['s'])
>res.add_property(cgi['p'], cgi['o'])
>
>// ????
>
>%>
>
>How do I save the newly created resource to the model?
I dont know this rdf-redland library, but you are probably better off using 
either the official redland ruby bindings (see librdf.org) or ActiveRDF 
[1]. For the first, if I remember correctly, you need to synchronise the
model to the database using Redland::librdf_model_sync(model).

But I would definitely recommend you to look at ActiveRDF: it gives you 
object-oriented access (using domain terminology) to your RDF:

eyal = Person.find_by_firstname('eyal')
p eyal.age
eyal.knows.each { |friend| p friend.age }

 -eyal

[1] http://activerdf.org


More information about the redland-dev mailing list