Refactor: replace "render :json = graph.to_json" to view template(show.json.erb).

Because model shouldn't know about view logic.
This commit is contained in:
Sato Hiroyuki 2013-03-06 20:31:28 +09:00
parent 9dc46eee8e
commit 2f7f46b256
5 changed files with 39 additions and 38 deletions

View file

@ -0,0 +1,26 @@
<% self.formats = ["html"] %>
<%= raw(
{
days: @graph.days.compact.map { |d| [d.day, d.strftime("%b")] },
commits: @graph.commits.map do |c|
{
parents: c.parents.collect do |p|
[p.id,0,0]
end,
author: {
name: c.author.name,
email: c.author.email,
icon: gravatar_icon(c.author.email, 20)
},
time: c.time,
space: c.spaces.first,
parent_spaces: c.parent_spaces,
refs: join_with_space(c.refs),
id: c.sha,
date: c.date,
message: c.message,
}
end
}.to_json
) %>