(continued - hit tab enter ;-)
1) We needed to launch our new website 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 )
2) rails with some custom code to render pages from the other environment (
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
_______________________________________________
Radiant mailing list
Post: [email protected]
Search: http://radiantcms.org/mailing-list/search/
Site: http://lists.radiantcms.org/mailman/listinfo/radiant