Created
February 24, 2010 09:18
-
-
Save tomafro/313277 to your computer and use it in GitHub Desktop.
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 Message | |
extend ActiveModel::Naming | |
include ActiveModel::Serializers::Xml | |
include ActiveModel::Serializers::JSON | |
def self.for_subscriber(subscriber_id) | |
# nasty! | |
5.times.collect { Message.new } | |
end | |
def attributes | |
{'id' => id, 'content' => content} | |
end | |
def content | |
Faker::Lorem.sentences(1 + rand(4)).join(" ") | |
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 SubscriberMessagesController < ApplicationController | |
respond_to :json, :xml | |
def index | |
respond_with Message.for_subscriber(params[:subscriber_id]) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment