Forum: Radiant CMS Using Rails methods in Radiant Plugins?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
78b41a243b4657853813db803786deee?d=identicon&s=25 David Piehler (lackoflove)
on 2007-03-22 17:55
Last week I successfully deployed a website on Radiant. Yeah! This week
I've been struggling to extend the site with two different tools.

The first is a simple page protection system that forces some public
pages to require a password before their content is shown. Easy
enough... I think.

I kind of assumed I would be able to rely on some Rails helper methods
such as redirect_to(). Am I wrong, or am I just setting up my plugin

Here's the basic outline of my plugin:

# /vendor/extensions/page_protect/page_protect_extension.rb

class PageProtectExtension < Radiant::Extension
  version "1.0"
  description "Adds PageProtect tags to force logins on specified pages"

  #define_routes do |map|

  def activate
    Page.send :include, PageProtect

# /vendor/extensions/page_protect/lib/page_protect.rb

module PageProtect
  include Radiant::Taggable

  def cache_page?

  tag 'pageprotect' do |tag|

  tag 'pageprotect:lockdown' do |tag|
    # use Rails redirect_to() to send user to the login screen
    redirect_to(:controller => "/login")

  tag 'pageprotect:loginform' do |tag|
    # output the HTML form stuff here


When I include the radius tag <r:pageprotect:lockdown /> in a page, I
see the following error:
"undefined method `redirect_to' for #"

Any help is much appreciated!
5f5f17e8b50d7ed41c61840e5a4cf9df?d=identicon&s=25 Sander de Goeij (Guest)
on 2007-03-22 20:33
(Received via mailing list)
On 3/22/07, David Piehler <> wrote:
>   end
> end
> [/code]

Hi David,

redirect_to is a method of ActionController::Base. In your code, you
include your tags and methods into the Page *model*, which doesn't
inherit from ActionController. Hence the undefined error.

Try creating a helper method that redirects to the login page and call
that from your tag.

Good luck,
Sander de Goeij
78b41a243b4657853813db803786deee?d=identicon&s=25 David Piehler (lackoflove)
on 2007-03-23 15:34
Thanks for the suggestion. I'm still trying to chisel away at the three
years of OO-PHP burned into my brain.
This topic is locked and can not be replied to.