Despite much googling and book checking, I can''t for the life of me figure out how to check if the time_zone object is nil. The situation is that I built a fun little delayed email delivery app -- http://mailthislater.com if you''re interested -- and want to ensure that the user selects his time zone. I can validate, throw errors on, and rescue all the other form fields. I tried checking in the before_filter that creates the time zone object, in the create method, but no dice. I think I''m just not understanding some of the basics - so I''m sorry if this isn''t even a meaningful question. Would it help if I posted controller code? Thanks.
2009/6/12 Jon <JonathanGCohen-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:> > Despite much googling and book checking, I can''t for the life of me > figure out how to check if the time_zone object is nil. The situation > is that I built a fun little delayed email delivery app -- http://mailthislater.com > if you''re interested -- and want to ensure that the user selects his > time zone. I can validate, throw errors on, and rescue all the other > form fields. I tried checking in the before_filter that creates the > time zone object, in the create method, but no dice. I think I''m just > not understanding some of the basics - so I''m sorry if this isn''t even > a meaningful question. Would it help if I posted controller code? > Thanks.validates_presence_of will check that a value has been entered for a field so may do what you are looking for. Colin
You can do validates_presence_of :time_zone in the relevant model to ensure that the field is not left blank.
Thanks Ryan, Colin -- I should have gone with my first instinct to validate in the model. Works now! On Jun 12, 8:11 am, Ryan Bigg <radarliste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> You can do validates_presence_of :time_zone in the relevant model to > ensure that the field is not left blank.