# Doing forms -- thinking way outside the box

**URL:** <https://www.ruby-forum.com/t/doing-forms-thinking-way-outside-the-box/91318>\
**Category:** Radiant CMS\
**Created:** [April 6, 2007, 6:36pm UTC](https://www.ruby-forum.com/t/doing-forms-thinking-way-outside-the-box/91318 "2007-04-06T18:36:36Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![orff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/b38774/32.png) [@orff](https://www.ruby-forum.com/u/orff)\
**Post date:** [April 6, 2007, 6:36pm UTC](https://www.ruby-forum.com/t/doing-forms-thinking-way-outside-the-box/91318/1 "2007-04-06T18:36:36Z")

</div>

1. We needed to launch our new website [lighthouse.org](http://lighthouse.org)
2. We needed complicated forms

---

<div class="post-metadata">

**Author:** ![orff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/b38774/32.png) [@orff](https://www.ruby-forum.com/u/orff)\
**Post date:** [April 6, 2007, 6:48pm UTC](https://www.ruby-forum.com/t/doing-forms-thinking-way-outside-the-box/91318/2 "2007-04-06T18:48:53Z")

</div>

(continued - hit tab enter 😉

1. We needed to launch our new website [lighthouse.org](http://lighthouse.org)
2. We needed complicated forms:

- donations forwarding to payflow link
- location based search, google maps integration
- GOOD AR validations, I love rails validation and didnt want to have  
to  
write a rediant behavior.

What I really wanted was radiant for the ‘static’ content and  
uninhibited  
rails for the forms and apps. This allows me to do anything I want for  
forms, searches, etc.

Here is our solution in a nutshell – 2 environments:

1. radiant with a snippet for the other environments url (  
[lighthouse.org](http://lighthouse.org) )
2. rails with some custom code to render pages from the other  
environment (  
[forms.lighthouse.org](http://forms.lighthouse.org))

To see a demo, go to the site and click ‘Help Near You’ or ‘Donate’,  
then  
‘Donate Online’

If anyone is interested in the source code, I will happily share it. I  
am  
not sure how well this could translate into a gem or a plugin though  
since  
it is essentially a standalone app.

Here is a snippet of a controller in the forms server environment, so  
you  
can see how easy it is for us to create forms now and still use radiant  
for  
the layout:

class DonateController \< ApplicationController

```
def index
    redirect_to :action => 'new'
end

def new
    @event_name = 'Online Donation'## label used on forms and in the

```

controller

```
    @form_var_name = 'donation' ## used in the shared/_contact form

```

partial which gets called in the new view

```
    if event_params = @params['donation']
        @donation= OnlineDonation.new(@params['donation'])

        ##SET EVENT TYPE -- DIFFERENT FOR EACH METHOD -- event_type

```

field in the Database  
@donation.event\_type = ‘Online Donatation’

```
        #raise @event.inspect ## dubugging for checking before

```

submitting  
if @donation.save  
flash[:notice] = @event\_name + ’ was successful.’  
redirect\_to :action =\> ‘success’, :id=\>@donation.id  
else  
flash[:error] = @event\_name + ’ could not be accepted.’  
@radiant\_html = process\_radiant\_layout( :page\_id=\>40,  
:title=\>‘Donate to the Lighthouse’) ## in application.rb  
render\_text @radiant\_html  
end  
else  
@radiant\_html = process\_radiant\_layout( :page\_id=\>40,  
:title=\>‘Donate to the Lighthouse’) ## in application.rb  
render\_text @radiant\_html  
end  
end

```
def success
    @event = OnlineDonation.find(@params['id'])
    @radiant_html = process_radiant_layout(:page_id=>40,

```

:title=\>‘Thanks’) ## in application.rb  
render\_text @radiant\_html  
end

end

the process\_radiant\_layout method is in the application.rb. What is  
does is  
connect to the radiant database and process all of the tags using  
recursion,  
then uses the local view in place of the content. So the local view for  
the  
new action will be just like and rails app. The main difference is we  
dont  
use rails layouts, we have code to render a specific radiant page’s  
layout  
(redirecting all links back to the other environment).

-mike

---

<div class="post-metadata">

**Author:** ![orff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/b38774/32.png) [@orff](https://www.ruby-forum.com/u/orff)\
**Post date:** [April 7, 2007, 11:51pm UTC](https://www.ruby-forum.com/t/doing-forms-thinking-way-outside-the-box/91318/3 "2007-04-07T23:51:34Z")

</div>

> Having a Radiant site for the CMS and content
> 
> Having a seperate Ruby on Rails sponsorship site for managing users  
> (with forms, and more…)

Comatose was designed for this purpose: [http://comatose.rubyforge.org/](http://comatose.rubyforge.org/)

Not as powerful as Radiant, but excellent for dead-simple page  
management in another Rails app

-jamie

---

<div class="post-metadata">

**Author:** ![orff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/b38774/32.png) [@orff](https://www.ruby-forum.com/u/orff)\
**Post date:** [April 8, 2007, 2:53am UTC](https://www.ruby-forum.com/t/doing-forms-thinking-way-outside-the-box/91318/4 "2007-04-08T02:53:45Z")

</div>

Thanks, but I think it will be too simple for what we need.

---

<div class="post-metadata">

**Author:** ![orff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/b38774/32.png) [@orff](https://www.ruby-forum.com/u/orff)\
**Post date:** [April 6, 2007, 10:35pm UTC](https://www.ruby-forum.com/t/doing-forms-thinking-way-outside-the-box/91318/5 "2007-04-06T22:35:26Z")

</div>

Looks pretty spiffy mike.

I would be interested in getting ahold of your code. I was planning  
on doing the same thing, for Kupenda. (currently  
[http://www.kupenda.org/](http://www.kupenda.org/) and [http://kupenda.jotapajaro.com/](http://kupenda.jotapajaro.com/))

that is:

Having a Radiant site for the CMS and content

Having a seperate Ruby on Rails sponsorship site for managing users  
(with forms, and more…)

I was going to go with the low-tech/hard-coding of sharing a design  
and linking between them… but if you’ve got something good for me  
to start from, I’d love to take a look at your code.

thanks,  
Jacob
