Displaying 20 results from an estimated 60000 matches similar to: "passing parameters to filters"
2005 Dec 15
2
Passing parameters to before_filter methods
I have a method that checks for a given role. I want to write
something in my controllers like
before_filter :check_roles(''admin'')
Which will ensure the current user has the admin role. Is it possible
to pass parameters in this way?
Ian
2006 May 11
1
skipping filters
I have a simple login scheme in application.rb. Something like
:requires_login is called in any controller as a before_filter. All is
good, except I''m having trouble figuring out how to make the public
login actions skip this before filter. Here''s what I have:
application.rb
skip_before_filter :requires_login, :only => [:login, :logout,
:confirm_valid_login]
2006 Jul 09
2
filters
Hi,
...i''m fairly new to ruby on rails, so maybe this is a simple question,
but i''ve been racking my wits for a while now, but i can''t figure out
why this isn''t working...
i''m implementing some kind of a questioniere, so that when a user picks
a certain answer, the value of that answer goes into a session variable
that stores the amount of points
2006 May 08
3
Can you have multiple before filters?
Hi,
Is it possible to specify multiple before filters in a controller...
here''s the thing: only one set of filters is to use the :except option.
Something like:
before_filter :check_for_session_cookie
before_filter :validate_user :except =>[''login'']
which I use to a) check if the user has returned to the site and has a
saved cookie holding login details b) check
2007 Aug 27
2
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.
2006 Nov 04
0
filter function with parameter
hey,
i have found your post about filter function with parameters:
Hi!
I want to add a function with a static paramter ("2" in the example) to
a filter, but somehow Rails seems to be looking for another syntax.
before_filter :check_quantity(2), :only => [:show]
doesn''t work. What''s the right way to do this?
Thanks a lot!
---------------------------------
Can
2007 Mar 20
1
Passing Arguments to before_filter
I want to put a before_filter in application.rb, as follows:
before_filter :do_something, :except_controller => [:admin]
def do_something(options)
options.stringify_keys!
unless options[:except_controller].include?(controller_name)
# do something useful
end
end
Where I''m blocking is on how to get the ''options'' data in the do_something
method. I think I
2008 Jun 04
5
controller filters running twice in 1.1.4?
since upgrading to 1.1.4 (I had been running without issue on a git
snapshot), I''m noticing that my filter actions initiated from application.rb
seem to be running twice. I created a test rails project with the rspec
scaffold and am also seeing the same behavior here too.
Adding this code to application.rb:
before_filter :foo
def foo
"foo"
end
and an example
2006 Jun 04
5
filter function with parameter
Hi!
I want to add a function with a static paramter ("2" in the example) to
a filter, but somehow Rails seems to be looking for another syntax.
before_filter :check_quantity(2), :only => [:show]
doesn''t work. What''s the right way to do this?
Thanks a lot!
--
Posted via http://www.ruby-forum.com/.
2006 Aug 23
0
Caches_action/ before_filter problem .
Hello, I have a method called "check_permission" that is set to run as a
before_fitler and which checks if a user has the authorization to view a
page.
This page is displayed through the method "show" which is cached through
the tag "caches_action :show"
My problem is that once a user with authorization to a page accesses it,
then afterwards all users (with or
2008 Jan 30
1
Can before_filter using Proc and specify block ?
Hi,
I see from this post
http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/97e333daab05b725/8252c90cb9c36f6d?lnk=gst&q=passing+parameter+before_filter#8252c90cb9c36f6d
it can specify the Proc in the before_filter function, but when
specify when action apply this filter, it raise an syntax error, such
as rthe following code
before_filter {|controller|
2008 Oct 06
2
Filter inheritance
can anyone tell me how before filter can call the private method audit
which from the parent class ?
because the bank controller has a private method called audit, this one
should not be inheritance by VaultController, so how the before_filter
use the private method audit ?
if the child class can use the parent class private method . does it
break encapsulation ? does the private has any sense
2006 Jul 14
4
sending additional parameters to before_filter
i am trying to create a system so that different users have different
priviliges on my application. i was going to modify my authorize
function so that i could pass the required role to it and have it check
the current user for that role.
i am using before_filter and would like to have just one function
instead of writing one for each role like so:
authorize(role)
instead of:
2006 Feb 27
3
Send parameter along with method in before_filter
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
2006 Jul 18
6
before_filter chains and halting at an arbitrary filter
Hi--I''m trying to implement a 2-level authentication system, where I
have one before_filter which does general user authentication, and
another which does further authorization for a specific controller. I
have it set up as follows:
before_filter :authorize_level_2
prepend_before_filter :authorize_level_1
which causes authorize_level_1() to run, and then authorize_level_2().
2006 May 16
2
before_filter and the application controller
Hi there,
I''m having a bit of an issue with my before_filter. I know that the filters
put in the application.rb controller are global for all the controllers. In
my application filter I''d like to allow access to the RSS feed method in a
''member'' controller and skip the login checks that the before_filters are
currently performing.
In my application my filters
2008 Sep 23
1
help required for passing parameters to rsync within a script
I'm attempting to write a short script to copy all 'CONC*' files in any
subdir under ./ using rsync and filters but I can't get the correct
quoting/escaping... any ideas?
eg cmd line (all on a single line):
/home/horace/mccssmb2/src/rsync-2.6.9__icc/rsync --times --links -z
--progress --stats -v -rP --filter='+ */' --filter='+ CONC*' --filter='-
*' .
2006 Apr 22
0
Sending arguments to filter methods
I want to set up a before_filter, and I want to be able to pass it
some parameters. My method looks like
def my_filter(a)
...
end
And I want to do
before_filter :myfilter ''a''
I''ve tried the above and
before_filter :myfilter, ''a''
but neither one is acceptable. How can I specify an argument to pass
in to the filter method?
Pat
2006 Oct 09
1
restful authentication - filtering out login ??
i am unable to reach the login page when adding ''before_filter
:login_required'' to the application controller.
I HAVE added the following to my sessions controller
''before_filter :login_required, :except => [:new, :create, :destroy]''
I figured this would overload the app controller filter but i get this
loop while it looks for sessions/new and isnt allowed
2006 Aug 03
1
strange before_filter error. is this a bug i have found?
...
before_filter :find_regression_test
def find_regression_test
@regression_test=RegressionTest.find(8)
end
....
The above seems like perfectly normal before_filter syntax, but it gives
this error. Aldo is no application trace, just a framework trace:
Any idea what is wrong?
NoMethodError in Regression testsController#modify_regression_test
private method `equal?''