diff --git a/app/models/user_certification.rb b/app/models/user_certification.rb index e29b17c..e1694c4 100644 --- a/app/models/user_certification.rb +++ b/app/models/user_certification.rb @@ -5,4 +5,12 @@ class UserCertification < ActiveRecord::Base belongs_to :user belongs_to :certification + + def user_name + if user.blank? + return "n/a (user ##{user_id} missing)" + else + return self.user.name + end + end end diff --git a/app/views/user_certifications/index.html.erb b/app/views/user_certifications/index.html.erb index 391f4fc..0ef5b64 100644 --- a/app/views/user_certifications/index.html.erb +++ b/app/views/user_certifications/index.html.erb @@ -5,9 +5,9 @@ <% @grouped_user_certs.sort.each do |cert, user_certifications| %>
<%= cert.name %>
- <% user_certifications.sort{|a,b| a.user.name <=> b.user.name}.each do |user_certification| %> + <% user_certifications.sort{|a,b| a.user_name <=> b.user_name}.each do |user_certification| %>
- <%= link_to user_certification.user.name, user_certification %> + <%= link_to user_certification.user_name, user_certification %>
<% end %>
diff --git a/app/views/user_certifications/show.html.erb b/app/views/user_certifications/show.html.erb index d12c3be..3ff98f4 100644 --- a/app/views/user_certifications/show.html.erb +++ b/app/views/user_certifications/show.html.erb @@ -1,6 +1,6 @@

User: - <%= @user_certification.user.name %> + <%= @user_certification.user_name %>

@@ -14,7 +14,12 @@

- Updated: by <%= link_to @updated_by.name, @updated_by unless @updated_by.blank? %> + Updated: by + <% if @updated_by.blank? %> + #<%= @user_certification.updated_by ||= "nil" %> + <% else %> + <%= link_to @updated_by.name, @updated_by %> + <% end %> at <%= @user_certification.updated_at %>