Guest User

Untitled

a guest
Jul 16th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. class ProfessionalReportsController < ApplicationController
  2. # GET /professional_reports
  3. # GET /professional_reports.xml
  4. #def index
  5.  
  6. #@professional_reports = ProfessionalReport.all
  7. #@professional_reports = ProfessionalReport.find(params[:user_information_id, :value => @user.id])
  8.  
  9. # LOGIC : if the user that is logged in does not have a professional report the matches the current year, it will direct the person to create a new report
  10.  
  11. # if @user_informations.professional_report.report_year != Time.new.strftime("%Y")
  12.  
  13. # if @professional_reports.any? {|rep| rep.report_year.nil?}
  14. # redirect_to(:action => "new")
  15. # else
  16. # redirect_to(:action => "edit")
  17. # end
  18.  
  19. # Ignore the following
  20. # case @professional_reports
  21. # when 0 then render :action => "new"
  22. # when 1 then render :action => "edit"
  23. # end
  24. #end
  25.  
  26. def index
  27. @professional_reports = @user.professional_reports
  28.  
  29. if @professional_reports.any? {|r| r.report_year == Time.now.year}
  30. #Evaluated as true, meaning the report DOES exist already, so edit it.
  31. redirect_to(:action => "edit")
  32. else
  33. #Evaluated as false, meaning the report does NOT exist, so create a new one.
  34. redirect_to(:action => "new")
  35. end
  36. end
Add Comment
Please, Sign In to add comment