Can FILTERS AND VERIFICATION functions take arguments?

Hi,

I have some problems in using filter. My filter functions need to have
arguments, but filter functions take only symbol that refer to
function name. Consider the following code:

class BlogController < ApplicationController

before_filter :authorize

For instance, authorize need arguments. So how can I pass arguments to
filter function?

Any helps always appreciate.

Sophy Eung wrote:

Hi,

I have some problems in using filter. My filter functions need to have
arguments, but filter functions take only symbol that refer to
function name. Consider the following code:

class BlogController < ApplicationController

before_filter :authorize

For instance, authorize need arguments. So how can I pass arguments to
filter function?

Any helps always appreciate.

what arguments does your filter need??

[email protected] wrote:

For instance, authorize need arguments. So how can I pass arguments to
filter function?

You can’t. It doesn’t really make sense to pass arguments to a filter.
But your before_filter can access the usual ActionController hashes
(params, session, etc) which is where you would put stuff that may vary
between requests.


Cheers,

  • Jacob A.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs