Skip to content
This repository was archived by the owner on Nov 18, 2020. It is now read-only.

Commit 947bfe6

Browse files
author
Todd Sedano
committed
Display who made last modification and when.
1 parent a057684 commit 947bfe6

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

app/models/page.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ class Page < ActiveRecord::Base
22
validates_presence_of :title
33
validates_presence_of :updated_by_user_id
44

5+
belongs_to :updated_by, :class_name=>'User', :foreign_key => 'updated_by_user_id'
6+
57
# acts_as_versioned :table_name => 'page_versions'
68

79
belongs_to :course

app/views/pages/show.html.erb

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,16 @@
66

77
<%= render :partial => "left_nav" %>
88

9+
910
<% if @page.course.blank? %>
1011
<h1 name="page"> <%=h @page.title %></h1>
1112
<% else %>
1213
<h1 name="course"><%=h @page.course.name %></h1>
1314
<h2 name="page"> <%=h @page.title %></h2>
1415
<% end %>
16+
<% if @page.editable?(current_user) %>
17+
<div class="right_link"><%= link_to 'Edit Page', edit_page_path(@page) %></div>
18+
<% end %>
1519

1620
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
1721
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.3/jquery-ui.min.js" type="text/javascript"></script>
@@ -65,14 +69,9 @@
6569
</div>
6670

6771
<% end %>
68-
69-
<h3>debug stuff</h3>
70-
<p>
71-
<b>Sequence number:</b>
72-
<%=h @page.position %>
73-
</p>
74-
75-
72+
<div class="modified">Last modified by <%= @page.updated_by.human_name %></div>
73+
<div class="modified"><%= time_ago_in_words(@page.updated_at) %> ago</div>
74+
<br/>
7675

7776
<%= link_to 'Edit', edit_page_path(@page) %> |
7877
<%= link_to 'Back', pages_path %>

public/stylesheets/site.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,4 +256,9 @@ border-width:1px;
256256
#email_subject_header {
257257
width: 70px;
258258
float: left;
259+
}
260+
261+
/* Used in pages */
262+
div.modified {
263+
text-align: right;
259264
}

0 commit comments

Comments
 (0)