Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Recommended rdf usage in Ruby on Rails

I'd like to publish rdf in my rails apps. What's the right way to do it?

like image 259
helcim Avatar asked Feb 26 '23 06:02

helcim


1 Answers

(For people who are interested in working with actual RDF data, please see The State of RDF in Ruby.)

The short answer to your question: You're looking for respond_to. In general, you'd write something like:

class PeopleController < ApplicationController::Base
  respond_to :html, :rdf

  def index
    @people = Person.all
    respond_to do |format|
      format.html
      format.rdf { convert_to_rdf(@people) }
    end
  end
end

Of course, you'll have to write 'convert_to_rdf'. You might find that RDF.rb is helpful for that.

like image 125
emk Avatar answered Mar 11 '23 02:03

emk