Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't work with Date #3

Closed
naumov opened this issue Jun 19, 2010 · 3 comments
Closed

Don't work with Date #3

naumov opened this issue Jun 19, 2010 · 3 comments
Labels

Comments

@naumov
Copy link

naumov commented Jun 19, 2010

Raises "undefined method `to_i' for ... :Date" when valildatable value is a Date
rails 3 beta4

@txus
Copy link
Member

txus commented Jun 20, 2010

Sorry, I couldn't apply your pull request because it breaks a spec (the one checking the :after_or_equal_to clause).
Turns out that somehow comparing two equal datetimes or times with >= (but not with <=) returns false. I've been researching but the best solution I found a couple days ago was to convert them to integer before comparing them; now I've fixed that Date thing converting all TimeWithZones and Dates to datetime before the to_i, so there should be no problem now.
Let me know if you find out about that datetime comparison strange issue, maybe it's my ruby version or I don't know! And thank you for contributing ;)

@naumov
Copy link
Author

naumov commented Jun 20, 2010

Thanks for so quick fix! :)

But there is small issue in your fix, too. It is when you do value = value.to_datetime and then pass record.errors.add(... :value => value ...). The original value is a Date, but the one is passed to i18n error message is an Datetime(becouse you convert the value directly). This couse a small issue with formatting in error messages.

I think it is better to introduce a new variable for comparison, but pass the original one to i18n error.

@txus
Copy link
Member

txus commented Jun 20, 2010

Yep! fixed. However I'm thinking this actually means that the i18n part is not covered by tests, so I think maybe tomorrow I'm giving it a try and get it covered to avoid future bugs!

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants