class MessagesController < ApplicationController respond_to :html, :json def show id = params[:id].to_i @widget = { id: id, user_id: (id+1) % 3 + 1, body: "This is the body of message #{id}." } # sleep 1 respond_with @widget end def create @widget = { id: Random.new.rand(100) + 200, user_id: params[:user_id], body: params[:body] } respond_with @widget, location: nil end end