Newbie ruby string match question


#1

All,

I want to know in the Application.rb controller if I’m on the login
screen.

When I’m on the page I care about the controller variable is
“#ActiveRbac::UserController:0x408b3d6c

So I want something like:
if controller contains ActiveRbac::UserController

What is the right syntax for the above?

Thanks
Greg

Greg F.
The Norcross Group
Forensics for the 21st Century


#2

Controller and Action are passed in via the that params hash for every
request. Remember that rails does some url magic to make this

“/hello/world”

more or less mean this

“/dispatch.cgi?controller=hello&action=world”

So you can write a line like this:

do_something if params[:controller] == ‘hello’

Which will fire off on all requests to your HelloController.

Greg F. wrote:

All,

I want to know in the Application.rb controller if I’m on the login
screen.

When I’m on the page I care about the controller variable is
“#ActiveRbac::UserController:0x408b3d6c

So I want something like:
if controller contains ActiveRbac::UserController

What is the right syntax for the above?

Thanks
Greg

Greg F.
The Norcross Group
Forensics for the 21st Century


#3

Thanks

That did the trick

On 5/5/06, Alex W. removed_email_address@domain.invalid wrote:

When I’m on the page I care about the controller variable is
Greg F.


Greg F.
The Norcross Group
Forensics for the 21st Century