I think you must have something in your code (plugin perhaps?) that is
mucking with the verify.  Here's the environment I'm using to try do
duplicate your problem:

About your application's environment
Ruby version              1.8.7 (powerpc-darwin9.7.0)
RubyGems version          1.3.5
Rack version              1.0
Rails version             2.3.2
Active Record version     2.3.2
Action Pack version       2.3.2
Active Resource version   2.3.2
Action Mailer version     2.3.2
Active Support version    2.3.2
Application root          /Users/rick/matt
Environment               development
Database adapter          sqlite3
Database schema version   20091206142727

I did a 'rails matt' followed by 'script/generate scaffold Page
title:string body:text' just to gin things up.  I've also added

 map.index '/', :controller => 'pages', :action => 'index'

to my routes.rb and removed public/index.html.

To be successful, my verify line must look like:

class PagesController < ApplicationController
  verify :method => :post,
        :only => [:edit, :destroy, :revert],
        :add_flash => { :notice => 'Cannot do that...'},
        :redirect_to => :index_path

or

class PagesController < ApplicationController
  verify :method => :post,
        :only => [:edit, :destroy, :revert],
        :add_flash => { :notice => 'Cannot do that...'},
        :redirect_to => 'index_path'

If I use

class PagesController < ApplicationController
  verify :method => :post,
        :only => [:edit, :destroy, :revert],
        :add_flash => { :notice => 'Cannot do that...'},
        :redirect_to => index_path

My app fails on the verify producing:

undefined local variable or method `index_path' for
PagesController:Class


I would suggest you start a simple test app, like this, and then
incrementally add to it any plugins you need.

Regardless, your use of :redirect_to => root_path (without quotes or
colon) is what is producing the error.

Is your experience the same if you use :redirect_to => 'root_url' ?

How about :redirect_to => {
  :controller => 'pages',
  :action => 'show',
  :name => 'HomePage'
  }


On Dec 6, 9:56 am, Matt Harrison <[email protected]> wrote:
> On Sun, Dec 06, 2009 at 06:37:38AM -0800, Rick wrote:
> > Matt,
>
> > I believe in your controller you want to use:
>
> > :redirect_to => 'root_path'
>
> Hi, thanks for the reply. Unfortunately that redirects me literally 
> tohttp://myhost.tldroot_path
>
> I just tried named routes from inside a view and they work as expected. It's
> only when I come to use the in a controller that they fail. I've also
> compared this project with a previous one I made that used named routes, and
> they appear to be used in exatly the same way.
>
> Thanks
>
> Matt

--

You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.


Reply via email to