Skip to content

Commit 41fb69b

Browse files
committed
remove similiar codes in dashboard based on code climate
1 parent e48c1db commit 41fb69b

File tree

1 file changed

+8
-17
lines changed

1 file changed

+8
-17
lines changed

app/admin/dashboard.rb

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,14 @@
1515
end
1616
end
1717

18-
column do
19-
panel "最近的文章" do
20-
ul do
21-
Post.limit(15).map do |post|
22-
omited_title = post.title.truncate(99, separator: ' ', omission: '...')
23-
li link_to(omited_title, system_post_path(post))
24-
end
25-
end
26-
end
27-
end
28-
29-
column do
30-
panel "最近的代码" do
31-
ul do
32-
Code.limit(15).map do |code|
33-
omited_title = code.title.truncate(99, separator: ' ', omission: '...')
34-
li link_to(omited_title, system_code_path(code))
18+
{Post: "最近的文章", Code: "最近的代码"}.each_pair do |key, value|
19+
column do
20+
panel value do
21+
ul do
22+
key.safe_constantize.limit(15).map do |record|
23+
omited_title = record.title.truncate(99, separator: ' ', omission: '...')
24+
li link_to(omited_title, send("system_#{record}_path", record))
25+
end
3526
end
3627
end
3728
end

0 commit comments

Comments
 (0)