GithubHelp home page GithubHelp logo

Comments (5)

xaviershay avatar xaviershay commented on July 17, 2024

This is also an issue when you pass a lambda with no params to :after - it works in 1.8, but throws an argument error in 1.9, which is captured (incorrectly) by the non-specific rescue block, resulting in the unhelpful "restriction 'after' value was invalid" error.

To fix, only catch exceptions that you actually expect.

from validates_timeliness.

adzap avatar adzap commented on July 17, 2024

Sorry I missed this issue comment. Yes absolutely, fixed exception catching and latest version supports 1.9.

from validates_timeliness.

bjorntrondsen avatar bjorntrondsen commented on July 17, 2024

I just spent a couple of hours trying to figure this one out too.
I would not have had any trouble if the below section had contained all the localizations:

Rails 2.2+ using the I18n system to define new defaults:
en:
activerecord:
errors:
messages:
on_or_before: "must be equal to or before {{restriction}}"
on_or_after: "must be equal to or after {{restriction}}"
between: "must be between {{earliest}} and {{latest}}"

I got the "restriction 'on_or_after' value was invalid", and couldnt for the life of me figure out what was missing, since I had "on_or_after" in the localization file.
It turns out that every translation is needed, even if you're not using all.

Why not include the whole thing in the tutorial? Its only about 6 more lines...

Anyway, now that I got this solved, validates_timeliness is helping me a bunch.
Thanks for creating it!

from validates_timeliness.

adzap avatar adzap commented on July 17, 2024

Hi Sharagoz

Sorry man, that sucks this wasted you time and to be honest I had overlooked resolving this error for a while now. The tutorial is missing them just as an oversight, but I will add them in.

Ultimately this problem needs to be fixed properly and I will do that shortly so it doesn't catch anyone else out.

Adam

from validates_timeliness.

adzap avatar adzap commented on July 17, 2024

Sharagoz has confirmed this is fixed with latest commits

from validates_timeliness.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.