added a few things here. Firstly, I fixed the broken delete function with the admin page. Secondly, whenever you register for this application, we will automatically populate your user data to make the application functional. Seemed like the easiest way to do this

This commit is contained in:
Ken Johnson
2013-06-01 00:19:07 -04:00
parent 38fcc263bd
commit 0319cc4768
6 changed files with 177 additions and 2 deletions
+1 -1
View File
@@ -32,7 +32,7 @@ class AdminController < ApplicationController
end
def delete_user
user = User.find_by_id(params[:admin_id])
user = User.find_by_user_id(params[:admin_id])
if user && !(current_user.user_id == user.user_id)
user.delete
message = true
+5
View File
@@ -9,6 +9,11 @@ class UsersController < ApplicationController
def create
user = User.new(params[:user])
user.build_retirement(POPULATE_RETIREMENTS.shuffle.first)
user.build_paid_time_off(POPULATE_PAID_TIME_OFF.shuffle.first)
user.build_paid_time_off.schedule(POPULATE_SCHEDULE.shuffle.first)
user.build_work_info(POPULATE_WORK_INFO.shuffle.first)
user.performance.build(POPULATE_PERFORMANCE.shuffle.first)
if user.save
session[:user_id] = user.user_id
redirect_to home_dashboard_index_path
+4
View File
@@ -1,4 +1,8 @@
class Performance < ActiveRecord::Base
attr_accessible :comments, :date_submitted, :reviewer, :score
belongs_to :user
def reviewer_name
User.find_by_id(self.reviewer).full_name
end
end
+3
View File
@@ -16,6 +16,9 @@ class User < ActiveRecord::Base
has_many :performance, :foreign_key => :user_id, :primary_key => :user_id
def full_name
"#{self.first_name} #{self.last_name}"
end
def self.authenticate(email, password)
auth = nil
+1 -1
View File
@@ -34,7 +34,7 @@
<tbody>
<% @perf.each do |p| %>
<tr>
<td><%= p.reviewer %></td>
<td><%= p.reviewer_name %></td>
<td><%= p.date_submitted %></td>
<td><%= p.score %></td>
<td><%= p.comments %></td>