I have two models, being an Employee and a WorkingPattern. An instance of an Employee belongs_to an Working Pattern.
The Working Pattern looks like this
:id => :integer, :name => :string, :mon => :boolean, :tue => :boolean, :wed => :boolean, :thu => :boolean, :fri => :boolean, :sat => :boolean, :sun => :boolean I need to know if an Employee should be at work today. So, if today is a Tuesday and that employee's working pattern record reports that :tue = true then return true, etc. I don't have the option of renaming the fields on the WorkingPattern model to match the days names.
I know that
Time.now.strftime("%A") will return the name of the day. Then I figured out I can get the first 3 characters of the string by doing
Time.now.strftime("%A")[0,3] so now I have "Tue" returned as a string. Add in a downcase
Time.now.strftime("%A")[0,3].downcase and now I have "tue", which matches the symbol for :tue on the WorkingPattern.
Now I need a way of checking the string against the correct day, ideally in a manner that doesn't mean 7 queries against the database for each employee!
Can anyone advise?