The table(days_of_weeks) contains 8 columns , one is id, and rest constitues the days of week (sun,mon,tue ...) where the days of week holds either 0 or 1
I need to find rows whose sum of days of week is less than 3.
As a sql statement i can write
select id from days_of_week where (mon + tue + wed + thu + fri + sat + sun ) < 3;
I'm trying to query it from rails
DaysOfWeek.select(:id).where((:sun + :tue + :wed + :thu + :fri + :sat + :sun) < 3)
it shows error because its just a symbol, i tried .to_i , but with no luck.
I know i can directly query with a sql statement from rails, but i want to do it the rails? way.
Any solution