README

Path: README
Last Update: Thu May 31 14:53:23 EDT 2007

RadiantOnRails

www.rubyforge.org/projects/radiantonrails

Author:Matt Parrish, Pearware LLC
Email:mparrish@pearware.org
Website:www.pearware.org

This Radiant extension allows the user to build sites that combine the static CMS features of Radiant within a dynamic Rails applications. The extension currently allows Rails pages to coexist along with Radiant pages and for the Rails pages to include Radiant snippets in the view. This extension is currently designed to work with Radiant 0.6.1.

The next goal is to allow the Rails views to leverage Radiant layouts so that the entire site (static + dynamic pages) has a consistent look and feel, while keeping the design DRY.

The following steps need to be followed in order for this to work.

Getting Started

Rails Configuration

  1. Edit RAILS_ROOT/config/environment.rb and change the following line
         config.view_path = File.join(RADIANT_ROOT, 'app', 'views')
    

to

        config.view_paths << File.join(RAILS_ROOT, 'app', 'views')
        config.view_paths << File.join(RADIANT_ROOT, 'app', 'views')

This change will allow your views in RAILS_ROOT/app/views to be seen by rails.

  1. The next step is to edit config/routes.rb and add your routes to the top of the file

like described below. This is slightly different than the typical way of defining routes within the ActionController::Routing::Routes.draw do |map| end block that is typical of this file. Instead your file should look like this:

        class RailsRoutes
          def self.define_routes(map)
              # Route definitions go here
              #map.with_options(:controller => 'custom') do |custom|
              #  custom.index 'custom', :action => 'index'
              #end
          end
        end

        load File.join(RADIANT_ROOT, "config", "routes.rb")

You create your own routes within the define_routes method. The class must be named as RailsRoutes and have the define_routes class-level method.

  1. That’s it, there is no step 3! You can now develop the dynamic portion of

your Rails app like before.

Inserting Snippets in dynamic pages

As of right now, it is possible to insert a simple snippet that consists of text only (no radius tags). To insert a snippet into a dynamic page, simply create a helper class for the view which includes the RadiantOnRails::SnippetHelper module. For instance, if you have the file custom_helper.rb, this is what it would look like this:

        module CustomHelper
          include RadiantOnRails::SnippetHelper
        end

Then, in your view you could insert a snippet by giving the name of the snippet. If a snippet with that name does not exist, nothing will be inserted into the page.

        <%= insert_snippet("custom") %>

TODO

The next step is to allow the Rails pages to reuse the Radiant layouts.

[Validate]