I leave a notice in the flash and do a redirect from a before_filter.
Can someone confirm that the first request after this, i.e. the page I
redirect to, doesn’t/isn’t supposed to clear the flash?
–
View this message in context:
http://www.nabble.com/flash%2C-before_filter-and-redirect_to-t1367103.html#a3665933
Sent from the RubyOnRails Users forum at Nabble.com.
Lucifron wrote:
I leave a notice in the flash and do a redirect from a before_filter.
Can someone confirm that the first request after this, i.e. the page I
redirect to, doesn’t/isn’t supposed to clear the flash?
Environment
Ruby version 1.8.4 (i386-linux)
RubyGems version 0.8.11
Rails version 1.1.0
Active Record version 1.14.0
Action Pack version 1.12.0
Action Web Service version 1.1.0
Action Mailer version 1.2.0
Active Support version 1.3.0
Application root /home/ivar/work/notice
Environment development
app/controllers/application.rb
Filters added to this controller will be run for all controllers in
the
application.
Likewise, all the methods added will be available for all controllers.
class ApplicationController < ActionController::Base
before_filter :allow?
def allow?
if controller_name == ‘foo’
flash[:notice] = 'Not allowed to access foo! – Time: ’ +
Time.new.to_s
puts “****** Setting flash *******”
redirect_to :controller => ‘legal’, :action => “l1”
return false
end
true
end
end
app/controllers/foo_controller.rb
class FooController < ApplicationController
def foo
end
def bar
end
end
app/controllers/legal_controller.rb
class LegalController < ApplicationController
def l1
end
def l2
end
end
Webrick output
[2006-03-30 12:56:08] INFO WEBrick::HTTPServer#start: pid=2292
port=2500
****** Setting flash *******
127.0.0.1 - - [30/Mar/2006:12:56:18 CEST] “GET /foo HTTP/1.1” 302 96
- → /foo
127.0.0.1 - - [30/Mar/2006:12:56:18 CEST] “GET /legal/l1 HTTP/1.1” 200
407
- → /legal/l1
127.0.0.1 - - [30/Mar/2006:12:56:25 CEST] “GET /legal/l2 HTTP/1.1” 200
407
http://localhost:2500/legal/l1 → /legal/l2
[2006-03-30 12:57:08] INFO going to shutdown …
Not allowed to access foo! – Time: Thu Mar 30 13:03:07 CEST 2006
* <L1>
* <L2>
* <foo>
* <bar>
Legal#l1
Find me in app/views/legal/l1.rhtml
Not allowed to access foo! – Time: Thu Mar 30 13:03:07 CEST 2006
* <L1>
* <L2>
* <foo>
* <bar>
Legal#l2
Find me in app/views/legal/l2.rhtml
–
View this message in context:
http://www.nabble.com/flash%2C-before_filter-and-redirect_to-t1367103.html#a3668109
Sent from the RubyOnRails Users forum at Nabble.com.