Hi All, I have a quick question related to activerecord exist. Can we do a activerecord object exist method with a date field. Like Weather.exists?(:weather_date => 22/09/11 ) Can we do like above. Please clarify me. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Sep 16, 11:49 am, merbivore <eshward...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi All, > > I have a quick question related to activerecord exist. Can we do a > activerecord object exist method with a date field. > Like > > Weather.exists?(:weather_date => 22/09/11 ) > > Can we do like above. Please clarify me.Yes (you should use a date object or a string containing a date in a format the database will understand) The only caveat is that if the column is actually a datetime column then you need to check for the range of datetimes that make up that particular day) Fred -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Weather.exists?(:weather_date => 22/09/11 ) if data is a string containing ''22/09/11'' Check whether it works.. Weather.exists?(:weather_date => data.to_date ) or check date rdoc clearly for correct format -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.