Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class ProfessionalReportsController < ApplicationController
- # GET /professional_reports
- # GET /professional_reports.xml
- #def index
- #@professional_reports = ProfessionalReport.all
- #@professional_reports = ProfessionalReport.find(params[:user_information_id, :value => @user.id])
- # 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
- # if @user_informations.professional_report.report_year != Time.new.strftime("%Y")
- # if @professional_reports.any? {|rep| rep.report_year.nil?}
- # redirect_to(:action => "new")
- # else
- # redirect_to(:action => "edit")
- # end
- # Ignore the following
- # case @professional_reports
- # when 0 then render :action => "new"
- # when 1 then render :action => "edit"
- # end
- #end
- def index
- @professional_reports = @user.professional_reports
- if @professional_reports.any? {|r| r.report_year == Time.now.year}
- #Evaluated as true, meaning the report DOES exist already, so edit it.
- redirect_to(:action => "edit")
- else
- #Evaluated as false, meaning the report does NOT exist, so create a new one.
- redirect_to(:action => "new")
- end
- end
Add Comment
Please, Sign In to add comment