Hi all, I''ve just started working on another RoR project after a couple of months away. I''m having trouble with named routes, specifically root_* In previous apps I''ve used root_path and root_url without any problems, but in this project (2.3.2 - the same as my last project where I used it) it comes up undefined. I''ve double and triple checking my routes.rb, and it all appears fine. I''ve defined map.root and removed index.html. I just can''t think what could be causing this continuing problem. I had upgraded this app to 2.3.5 and thought that might have been the cause. I googled around for deprecation notices or anything and eventually regressed rails back to 2.3.2 with no change. I know I''ve probably missed something very simple, but it''s completely eluding me right now. Any insights you guys could send my way would be appreciated. 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Not sure what is the issue is, I am running 2.3.4 and it works fine. I do have he map.root as the first entry although I don''t think that will matter. Can you send your routes.rb file? Darian Shimy -- http://www.darianshimy.com http://twitter.com/dshimy On Tue, Dec 1, 2009 at 5:41 PM, Matt Harrison <iwasinnamuknow-ja4MoDZtUtVl57MIdRCFDg@public.gmane.org> wrote:> Hi all, > > I''ve just started working on another RoR project after a couple of months > away. I''m having trouble with named routes, specifically root_* > > In previous apps I''ve used root_path and root_url without any problems, but > in this project (2.3.2 - the same as my last project where I used it) it > comes up undefined. > > I''ve double and triple checking my routes.rb, and it all appears fine. I''ve > defined map.root and removed index.html. I just can''t think what could be > causing this continuing problem. > > I had upgraded this app to 2.3.5 and thought that might have been the cause. > I googled around for deprecation notices or anything and eventually > regressed rails back to 2.3.2 with no change. > > I know I''ve probably missed something very simple, but it''s completely > eluding me right now. Any insights you guys could send my way would be > appreciated. > > 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. > > >-- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Darian Shimy wrote:> Not sure what is the issue is, I am running 2.3.4 and it works fine. > I do have he map.root as the first entry although I don''t think that > will matter.Thanks for the reply Darian, I also have map.root as the first (uncommented) entry.> Can you send your routes.rb file?My entire routes.rb is available at http://pastie.org/723159, but please don''t laugh at my mess :D> Darian ShimyThanks 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Are you sure you restarted your server after introducing the map.root mapping ? Thanks & Regards, Dhruva Sagar. On Wed, Dec 2, 2009 at 2:13 PM, Matt Harrison <iwasinnamuknow-ja4MoDZtUtVl57MIdRCFDg@public.gmane.org>wrote:> Darian Shimy wrote: > > Not sure what is the issue is, I am running 2.3.4 and it works fine. > > I do have he map.root as the first entry although I don''t think that > > will matter. > > Thanks for the reply Darian, I also have map.root as the first > (uncommented) entry. > > > Can you send your routes.rb file? > > My entire routes.rb is available at http://pastie.org/723159, but please > don''t laugh at my mess :D > > > Darian Shimy > > 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > > >-- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Also you try *rake routes * to see all your routes. On Wed, Dec 2, 2009 at 12:46 AM, Dhruva Sagar <dhruva.sagar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote:> Are you sure you restarted your server after introducing the map.root > mapping ? > > Thanks & Regards, > Dhruva Sagar. > > > > > > On Wed, Dec 2, 2009 at 2:13 PM, Matt Harrison < > iwasinnamuknow-ja4MoDZtUtVl57MIdRCFDg@public.gmane.org> wrote: > >> Darian Shimy wrote: >> > Not sure what is the issue is, I am running 2.3.4 and it works fine. >> > I do have he map.root as the first entry although I don''t think that >> > will matter. >> >> Thanks for the reply Darian, I also have map.root as the first >> (uncommented) entry. >> >> > Can you send your routes.rb file? >> >> My entire routes.rb is available at http://pastie.org/723159, but please >> don''t laugh at my mess :D >> >> > Darian Shimy >> >> 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> >> . >> For more options, visit this group at >> http://groups.google.com/group/rubyonrails-talk?hl=en. >> >> >> > -- > 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. >-- Satyajit -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Satyajit Malugu wrote:> Also you try > *rake routes * > to see all your routes."root" appears as the first route in the list, and it looks properly formed: http://pastie.org/723163> On Wed, Dec 2, 2009 at 12:46 AM, Dhruva Sagar <dhruva.sagar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: > >> Are you sure you restarted your server after introducing the map.root >> mapping ?Yes the server has been restarted several times, I added the map.root right at the start of the project but I only just tried to use it. 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Can you post the error message and any info that appears in the log? On Dec 2, 3:53 am, Matt Harrison <iwasinnamuk...-ja4MoDZtUtVl57MIdRCFDg@public.gmane.org> wrote:> Satyajit Malugu wrote: > > Also you try > > *rake routes * > > to see all your routes. > > "root" appears as the first route in the list, and it looks properly formed: > > http://pastie.org/723163 > > > On Wed, Dec 2, 2009 at 12:46 AM, Dhruva Sagar <dhruva.sa...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: > > >> Are you sure you restarted your server after introducing the map.root > >> mapping ? > > Yes the server has been restarted several times, I added the map.root > right at the start of the project but I only just tried to use it. > > 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Wed, Dec 02, 2009 at 05:41:15AM -0800, Rick wrote:> Can you post the error message and any info that appears in the log?Thanks for the reply, I will get the information posted as soon as possible. I''m in hospital right now and have only just got internet access provided. As soon as I can get someone to turn on my dev machine I will be able to post the logs. Oh and no flowers or cards please, everyone is so depressingly cheerful it''s a wonder they are still alive :D 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
My apologies Rick, I didnt intent to send my reply only to you. Here is a copy for the list to peruse, including some extra information. Since my last mail I also tried some of the other named routes I have defined, and all of them come up undefined as well. There is obviously something strange going on, and I''m not sure if it''s me. On Wed, Dec 02, 2009 at 05:41:15AM -0800, Rick wrote:> Can you post the error message and any info that appears in the log?Ok here we go: Error message and backtrace from the logs can be found here: http://pastie.org/729055 <pages_controller.rb> 1 class PagesController < ApplicationController 2 verify :method => :post, :only => [ 3 :update, :create, :destroy, :revert 4 ], :redirect_to => root_path 5 6 def show ....... </pages_controller.rb> The routes.rb has been pastie''d in a previous post, but I will repeat the link here for reference (http://pastie.org/723159). You can also see the result of "rake routes" here http://pastie.org/729464. Please let me know if there is anything else I can provide. Many 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Matt, I believe in your controller you want to use: :redirect_to => ''root_path'' On Dec 5, 3:51 pm, Matt Harrison <iwasinnamuk...-ja4MoDZtUtVl57MIdRCFDg@public.gmane.org> wrote:> My apologies Rick, I didnt intent to send my reply only to you. Here is a > copy for the list to peruse, including some extra information. > > Since my last mail I also tried some of the other named routes I have > defined, and all of them come up undefined as well. There is obviously > something strange going on, and I''m not sure if it''s me. > > On Wed, Dec 02, 2009 at 05:41:15AM -0800, Rick wrote: > > Can you post the error message and any info that appears in the log? > > Ok here we go: > > Error message and backtrace from the logs can be found here:http://pastie.org/729055 > > <pages_controller.rb> > 1 class PagesController < ApplicationController > 2 verify :method => :post, :only => [ > 3 :update, :create, :destroy, :revert > 4 ], :redirect_to => root_path > 5 > 6 def show > ....... > </pages_controller.rb> > > The routes.rb has been pastie''d in a previous post, but I will repeat the > link here for reference (http://pastie.org/723159). > > You can also see the result of "rake routes" herehttp://pastie.org/729464. > > Please let me know if there is anything else I can provide. > > Many 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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 to http://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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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 <iwasinnamuk...-ja4MoDZtUtVl57MIdRCFDg@public.gmane.org> 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Sun, Dec 06, 2009 at 08:05:22AM -0800, Rick wrote:> 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'' > }Rick, many thanks for your reply. I believe I have sorted it now. If I use :redirect_to => :root_url it does appear to work as I expect. I realise that I wasn''t using verify in my last project, and it seems to take slighly different arguments than redirect_to. So for verify I will use the symbol :root_url but for redirect_to I will use the method root_url(). Many thanks for the help with this one, my head hasn''t been clear enough to work it out for myself, I might have to lay off the morphine for a while :D 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I use *redirect_to root_url* Thanks & Regards, Dhruva Sagar. On Sun, Dec 6, 2009 at 10:05 PM, Matt Harrison <iwasinnamuknow-ja4MoDZtUtVl57MIdRCFDg@public.gmane.org> wrote:> On Sun, Dec 06, 2009 at 08:05:22AM -0800, Rick wrote: > > 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'' > > } > > Rick, many thanks for your reply. I believe I have sorted it now. If I use > > :redirect_to => :root_url > > it does appear to work as I expect. I realise that I wasn''t using verify in > my last project, and it seems to take slighly different arguments than > redirect_to. > > So for verify I will use the symbol :root_url but for redirect_to I will > use > the method root_url(). > > Many thanks for the help with this one, my head hasn''t been clear enough to > work it out for myself, I might have to lay off the morphine for a while :D > > 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > > >-- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
You probably ought to save the morphine for when you''re feeling better... On Dec 6, 11:35 am, Matt Harrison <iwasinnamuk...-ja4MoDZtUtVl57MIdRCFDg@public.gmane.org> wrote:> On Sun, Dec 06, 2009 at 08:05:22AM -0800, Rick wrote: > > 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'' > > } > > Rick, many thanks for your reply. I believe I have sorted it now. If I use > > :redirect_to => :root_url > > it does appear to work as I expect. I realise that I wasn''t using verify in > my last project, and it seems to take slighly different arguments than > redirect_to. > > So for verify I will use the symbol :root_url but for redirect_to I will use > the method root_url(). > > Many thanks for the help with this one, my head hasn''t been clear enough to > work it out for myself, I might have to lay off the morphine for a while :D > > 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.