Forum: Ruby on Rails newbie ruby string match question

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Greg F. (Guest)
on 2006-05-05 19:38
(Received via mailing list)
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
Alex W. (Guest)
on 2006-05-05 20:32
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
Greg F. (Guest)
on 2006-05-05 22:41
(Received via mailing list)
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
This topic is locked and can not be replied to.