Jarl,
I've been listening in on this conversation and it brings to mind a
discussion a while back on the use of presenters and reverse
presenters.  Since the dawn of time, ActiveRecord (and perhaps even
ActiveModel) has been tightly wedded to the concept of unreliable
human input (= HTML forms).  Gradually there has been some decoupling,
but nothing comprehensive.  The idea of a "Presenter/Reverse
Presenter" is needed to insulate the persisted (and canonical) model
from various presentation/view layer technologies -you can perhaps
find some more background by googling those terms.

Consider using something other than validations -matthewrudyjacobs
"guard" macro seems like a reasonable step.  You might still need to
disable validations in various and sundry circumstances -bummer.

-Chris

On Jun 1, 5:15 am, Jarl Friis <[email protected]> wrote:
> "[email protected]" <[email protected]> writes:
> > Jarl,
> > I'm wondering in what context you end up with user input that outputs
> > a boolean?
>
> > Is it from a web form,
> > or XML,
> > or JSON
> > or  console app?
>
> Integration with an external system making REST calls to our app.
>
> > My feeling is that you're only going to end up with a true/false if
> > you are calling from a method inside your application,
> > eg.
>
> >   something.make_order(params, :balloon => true)
>
> > in which case "validation" may be the wrong use case.
>
> Yes, but as in most other rails application, the input comes from a
> http POST or PUT method, hence the input is unreliable and validation
> is wanted.
>
> > If you're trying to guard against your own input
> > then perhaps what you want to invent something like
>
> >   guard_field :balloon, :values => [true, false]
>
> I am trying to inform what-ever-have provided-the-input that the value
> is not acceptable.
>
> Here is an example A generic web-form, where all input fields are of
> type text (in the HTML form), but of course some fields (like
> :balloon) are typed, and therefore only certain values are
> accepted. The value "sand" (which means 'true' in danish) is not an
> acceptable boolean value, hence I would like a validation
> message. Currently this would silently be converted to false, which
> semantically means the complete opposite of what the user expected.
>
> Jarl

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en.

Reply via email to