ruby - If...Then... syntax issues -
i'm trying write app calculates sick/vacation days , how employee has available in either category. in employee model, vacation_days value determined hire-on date, , sick_days same employees, , separate "pools." latest roadblock trying determine how have time-off being subtracted appropriate pool.
here's employee model:
class employee < activerecord::base def remaining_vacation_days vacation_days - vacation_days_used end def remaining_sick_days sick_days - sick_days_used end def vacation_days_used if furlough.description == "vacation" furlough.duration end end def sick_days_used if furlough.description == "sick" furlough.duration end end
there's string column named :description in model handles date ranges (named furlough), , form radio-button 2 options 'sick' , 'vacation'. however, i'm having issues getting syntax right in employee model:
syntaxerror in employees#index showing /users/ryrythefrenchfry/rails_projects/time_tracker/app/views/employees/index.html.erb line #28 raised: /users/ryrythefrenchfry/rails_projects/time_tracker/app/models/furlough.rb:24: syntax error, unexpected $end, expecting keyword_end end ^ extracted source (around line #28): 25: <td></td> 26: <td><%= employee.years_employed %></td> 27: <td></td> 28: <td><%= employee.remaining_sick_days %></td> 29: <td></td> 30: <td><%= employee.remaining_vacation_days %></td> 31: <td></td>
when comment out *def vacation_days_used* , *def sick_days_used* goes through, know that's problem is, don't have enough understanding of i'm doing yet find answer in documentation. thank help!
you missing 1 more end
class. add last line in model file.
def sick_days_used if furlough.description == "sick" furlough.duration end end end
Comments
Post a Comment