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 incorrectly? Here's the basic outline of my plugin: [code] # /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| #end def activate Page.send :include, PageProtect end end [/code] [code] # /vendor/extensions/page_protect/lib/page_protect.rb module PageProtect include Radiant::Taggable def cache_page? false end tag 'pageprotect' do |tag| tag.expand end tag 'pageprotect:lockdown' do |tag| # use Rails redirect_to() to send user to the login screen redirect_to(:controller => "/login") end tag 'pageprotect:loginform' do |tag| # output the HTML form stuff here end end [/code] 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!
on 2007-03-22 17:55
on 2007-03-22 20:33
On 3/22/07, David Piehler <firstname.lastname@example.org> 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 email@example.com
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.