From 67c654ed1658b8a061e7f7d3effe0ff66ad60945 Mon Sep 17 00:00:00 2001 From: Pavel Pravosud Date: Mon, 28 Jul 2014 15:22:45 -0400 Subject: [PATCH] Make the first usage example less confusing [ci skip] --- README.md | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index caf3ff1..0ae50cf 100644 --- a/README.md +++ b/README.md @@ -16,26 +16,26 @@ generation process is fraught with conditionals and loops. Here's a simple example: ``` ruby -Jbuilder.encode do |json| - json.content format_content(@message.content) - json.(@message, :created_at, :updated_at) - - json.author do - json.name @message.creator.name.familiar - json.email_address @message.creator.email_address_with_name - json.url url_for(@message.creator, format: :json) - end +# app/views/message/show.json.jbuilder - if current_user.admin? - json.visitors calculate_visitors(@message) - end +json.content format_content(@message.content) +json.(@message, :created_at, :updated_at) - json.comments @message.comments, :content, :created_at +json.author do + json.name @message.creator.name.familiar + json.email_address @message.creator.email_address_with_name + json.url url_for(@message.creator, format: :json) +end - json.attachments @message.attachments do |attachment| - json.filename attachment.filename - json.url url_for(attachment) - end +if current_user.admin? + json.visitors calculate_visitors(@message) +end + +json.comments @message.comments, :content, :created_at + +json.attachments @message.attachments do |attachment| + json.filename attachment.filename + json.url url_for(attachment) end ```