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.
25bbc96d9c53647354cb724e744b2222?d=identicon&s=25 Greg Freemyer (Guest)
on 2006-05-05 17: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 Freemyer
The Norcross Group
Forensics for the 21st Century
D0cd6b10e01bacb976b3b815a9c660bc?d=identicon&s=25 Alex Wayne (Guest)
on 2006-05-05 18: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 Freemyer 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 Freemyer
> The Norcross Group
> Forensics for the 21st Century
25bbc96d9c53647354cb724e744b2222?d=identicon&s=25 Greg Freemyer (Guest)
on 2006-05-05 20:41
(Received via mailing list)
Thanks

That did the trick

On 5/5/06, Alex Wayne <rubyonrails@beautifulpixel.com> wrote:
>
> > When I'm on the page I care about the controller variable is
> > Greg Freemyer
>
--
Greg Freemyer
The Norcross Group
Forensics for the 21st Century
This topic is locked and can not be replied to.