From 054c736d6a912bc11ab6e6bdf39139c82b6e9cf9 Mon Sep 17 00:00:00 2001 From: albert Date: Sun, 10 Mar 2013 14:49:40 -0400 Subject: [PATCH] fixes #817 --- app/models/post.rb | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/app/models/post.rb b/app/models/post.rb index bc6a54ae6..418ec2829 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -837,17 +837,24 @@ class Post < ActiveRecord::Base options ||= {} options[:except] ||= [] options[:except] += hidden_attributes + # options[:methods] += [:uploader_name, :has_large] hash = super(options) - hash["uploader_name"] = uploader_name - hash["has_large"] = has_large hash end + + def to_json(options = {}) + options ||= {} + options[:methods] ||= [] + options[:methods] += [:uploader_name, :has_large] + super(options) + end def to_xml(options = {}, &block) # to_xml ignores the serializable_hash method options ||= {} - options[:except] ||= [] - options[:except] += hidden_attributes + options[:procs] ||= [] + options[:procs] << lambda {|options, record| options[:builder].tag!("uploader-name", record.uploader_name)} + options[:procs] << lambda {|options, record| options[:builder].tag!("has-large", record.has_large?, :type => "boolean")} super(options, &block) end