Here is code which is not working
class WeekDay < ActiveRecord::Base
validates_inclusion_of :day, :in => %w(sunday monday tuesday wednesday thursday friday saturday), :case_sensitive => false
end
Currently i have all of days in db except sunday. I am trying to add “Sunday”, and getting errors “is not included in the list”.
validates_inclusion_of does not have a case_sensitive argument, so you can create your own validator(if you are using Rails 3):
and save this in your lib directory as:
Then in your model, you can have:
Just make sure rails loads this lib file on startup by putting this in your config/application.rb: