Permalink
Browse files

render survey.to_json from rabl template. closes #288

  • Loading branch information...
1 parent 76cf808 commit f6dcb637346c26487d967b5139cadb470e43d106 Mark Yoon committed Apr 2, 2012
Showing with 6 additions and 7 deletions.
  1. +0 −7 app/views/surveyor/question.json.rabl
  2. +6 −0 lib/surveyor/models/survey_methods.rb
@@ -1,7 +0,0 @@
-attributes :api_id => :uuid
-node(:help_text, :if => lambda { |q| !q.help_text.blank? }){ |q| q.help_text }
-node(:type, :if => lambda { |q| q.display_type != "default" }){ |q| q.display_type }
-node(:reference_identifier, :if => lambda { |q| !q.reference_identifier.blank? }){ |q| q.reference_identifier }
-node(:pick, :if => lambda { |q| q.pick != "none" }){ |q| q.pick }
-node(:text){ |q| q.split_text(:pre) }
-node(:post_text, :if => lambda { |q| !q.split_text(:post).blank? }){ |q| q.split_text(:post) }
@@ -76,6 +76,12 @@ def inactive_at=(datetime)
self.active_at = nil if !datetime.nil? and !self.active_at.nil? and self.active_at > datetime
super(datetime)
end
+ def to_json
+ template_path = ActionController::Base.view_paths.find("export", ["surveyor"], false, {:handlers=>[:rabl], :locale=>[:en], :formats=>[:json]}, [], []).inspect
+ engine = Rabl::Engine.new(File.read(template_path))
+ engine.render(nil, {:object => self})
+ end
+
end
end
end

0 comments on commit f6dcb63

Please sign in to comment.