Forum: Ruby on Rails Send parameter along with method in before_filter

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.
E2489efc6ec10ec818b71965909ea109?d=identicon&s=25 Jin Lee (Guest)
on 2006-02-27 23:20
(Received via mailing list)
Hello list,

I have an app that has a very simple authorization scheme. A person can
have
many roles and roles can have many people.

In my app, I'd like to do

before_filter :login_required  (since no role name is provided, it
accepts
any users with credentials)
before_filter :login_required ("administrator") (only accepts those with
role administrator)
before_filter :login_required {"administrator", "buyer", "seller"}
(accepts
those with roles admin, buyer, seller)

Now, I know the only way you can achieve this is to use the lambda
function,
but to me it looks very ugly. Right now I have multiple before_filter,
first
checking if they are logged in, then checking their role, etc.

Is there any other way around this that Im not seeing? I tried to come
up
with an answer using sessions, but it got far too complicated.

Any help would be fantastic,

Jin
132a94ca65959bda6c74fae54bff2425?d=identicon&s=25 Ezra Zygmuntowicz (Guest)
on 2006-02-27 23:39
(Received via mailing list)
On Feb 27, 2006, at 2:18 PM, Jin Lee wrote:

> with role administrator)
>
> Any help would be fantastic,
>
> Jin
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails


Jin-

	I have a simple plugin that does thing for you with an easy
declarative syntax and then it defines all the before filters for
you. There is a write up here:

http://brainspl.at/articles/2006/02/20/new-plugin-acl_system

Cheers-
-Ezra Zygmuntowicz
Yakima Herald-Republic
WebMaster
http://yakimaherald.com
509-577-7732
ezra@yakima-herald.com
E2489efc6ec10ec818b71965909ea109?d=identicon&s=25 Jin Lee (Guest)
on 2006-02-28 19:10
(Received via mailing list)
Erza,

lovely! I was able to get your acl system running, and its working
smooth as
butter now. I wasn't being DRY in my code and this really cleaned things
up.
Thank you very much,

Jin
132a94ca65959bda6c74fae54bff2425?d=identicon&s=25 Ezra Zygmuntowicz (Guest)
on 2006-02-28 19:56
(Received via mailing list)
Lin-

	Your welcome! I'm glad you could use it. Please do give feedback if
you run into any issues or you have an idea you wold like to see
added to the plugin.

-Ezra

On Feb 28, 2006, at 10:08 AM, Jin Lee wrote:

>
> > with role administrator)
> complicated.
> Jin-
> WebMaster
>
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails

-Ezra Zygmuntowicz
Yakima Herald-Republic
WebMaster
http://yakimaherald.com
509-577-7732
ezra@yakima-herald.com
This topic is locked and can not be replied to.