Guest User

Untitled

a guest
Mar 7th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. <h2>Add A New Employee</h2>
  2.  
  3. <% form_for :employee, @employee, :url => :create do |f| %>
  4. <h3>Basic Information</h3>
  5. <p><em>First Name:</em> <%= f.text_field :first_name %></p>
  6. <p><em>Last Name:</em> <%= f.text_field :last_name %></p>
  7. <p><em>Username:</em> <%= f.text_field :username %></p>
  8. <p><em>Password:</em> <%= f.password_field :password %></p>
  9. <p><em>Confirm:</em> <%= f.password_field :password_confirmation %></p>
  10. <p>Manager? <%= f.check_box :manager %>
  11. <h3>Work Details</h3>
  12. <p><em>Start Time:</em> <%= f.text_field :start_time %></p>
  13. <p>Lunch Time: <%= f.text_field :lunch_time %></p>
  14. <p>Daily Lunch Hours: <%= f.text_field :daily_lunch_hours %></p>
  15. <p><em>Weekly Regular Hours:</em> <%= f.text_field :weekly_regular_hours %></p>
  16. <p>Annual Vacation Hours: <%= f.text_field :annual_vacation_hours %></p>
  17. <p>Annual Personal Hours: <%= f.text_field :annual_personal_hours %></p>
  18. <p>Annual Sick Hours: <%= f.text_field :annual_sick_hours %></p>
  19. <%= submit_tag "Create Employee Record" %>
  20. <% end %>
  21.  
  22. class EmployeesController < ApplicationController
  23.  
  24. before_filter :authenticate
  25. before_filter :manager_required
  26.  
  27. def new
  28. @employee = Employee.new
  29. end
  30.  
  31. def create
  32. @employee = Employee.new(params[:employee])
  33. if @employee.save
  34. flash[:notice] = "Employee was saved sucessfully"
  35. redirect_to :controller => :manager
  36. else
  37. render :action => "new"
  38. end
  39. end
  40. end
Add Comment
Please, Sign In to add comment