Search code examples
ruby-on-railsrubyrdf

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?


Solution

  • (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.