Abstracting a form

If you wanted to abstract or wrap a form in Rails, how would you do
it?

The purpose of this is to capture form-specific behavior–
preprocessing, basically–that doesn’t belong in a model.

Django, for example, works at this level:

http://docs.djangoproject.com/en/1.2/topics/forms/

Maybe a controller filter or private method would accomplish this, but
I don’t want to make the controller “fat.”

djangst wrote in post #977614:

If you wanted to abstract or wrap a form in Rails, how would you do
it?

What do you mean?

The purpose of this is to capture form-specific behavior–
preprocessing, basically–that doesn’t belong in a model.

Do you have a concrete example in mind?

Django, for example, works at this level:

http://docs.djangoproject.com/en/1.2/topics/forms/

Maybe a controller filter or private method would accomplish this, but
I don’t want to make the controller “fat.”

In all likelihood, you want another model – or maybe a presenter. But
it’s hard to say for sure until you describe the actual problem you’re
trying to solve.

Best,

Marnen Laibow-Koser
http://www.marnen.org
[email protected]

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs