Forum: Ruby on Rails Using render functions in my own classes

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
E. Vlieg (Guest)
on 2005-12-31 18:24
Hello!

I'm trying to create my own Form handler as a replacement of the default
scaffolding. Creating HTML forms has never been my favorite job.

What I have done:
- Created a new module FormHandler
- Added a class Form in the module
- Defined an initialize and to_s method. The initialize method receives
some basic information about the form, the to_s method returns a string
which contains the complete form.

The module wil be extended with FormElement classes, but I'm trying to
solve the following. In the to_s method, I would like to use
render_to_string :partial to render a template and return it as a
string. I managed to do this by extending ApplicationController::Base
and calling the function. The problem is that the method relies on the
contract that a request and response object are available.

Passing the response and request from the ApplicationController that
uses the FormHandler is an oppertunity, but is not very clean.

Is there any possibility to use the render functions of Rails without
the need to extend the Base class and the existens of the reponse en
request objects.

Thanks!

Edwin
This topic is locked and can not be replied to.