Created
May 5, 2014 17:54
-
-
Save whittle/76df2f1799713977ea4d to your computer and use it in GitHub Desktop.
Example roar-rails app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SiteFaqsController < ApplicationController | |
include Roar::Rails::ControllerAdditions | |
respond_to :hal | |
def show | |
respond_with SiteFaq.new('How do I understand recursion?', 'First, you must understand recursion.') | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SiteFaq < Struct.new(:question, :answer) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module SiteFaqRepresenter | |
include Roar::Representer::JSON::HAL | |
property :question | |
property :answer | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Mime::Type.register 'application/hal+json', :hal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Rails.application.routes.draw do | |
resources :site_faqs, only: [:show] | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment