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 the user has accumilated, so that in
the end i can pick that out and use it for my application (specifics,
not important)
so everything is good, until i want to reset the session to zero;
i want to reset the session when a certain params variable is equal to
zero - - i have a params[:question_number] in the action ( the uri looks
like www.localhost:3000/polls/questioniere/1?question_number=0)
so i decided to run a

before_filter :zeroize_point_if_start_questioniere

where i defined it

def…
if params[:question_number] == 0
@session[:aquired_points] = 0
end
end

it didn’t work.
i checked to see if the before_filter was running, and it was(i put a
false in there, and the page wasn’t rendered) and i also checked to see
if the params[:question_number] was read as zero, and the test also
worked out fine. (it read a zero)

the only thing left to be the problem is that because it is a
before_filter, it doesn’t read the params[:question_number] until after
the before_filter takes place.
but, then, how am i supposed to zeroize the points (according to the
page_number)? am i missing the problem, or is there something else i’m
missing?

thanks for any help,

u

Hi –

On Sun, 9 Jul 2006, unknown wrote:

not important)
def…
if params[:question_number] == 0
@session[:aquired_points] = 0
end
end

it didn’t work.

Try:

if params[:question_number] == “0”

I suspect that’s what’s going on.

David


http://www.rubypowerandlight.com => Ruby/Rails training & consultancy
http://www.manning.com/black => RUBY FOR RAILS, the Ruby book for
Rails developers
http://dablog.rubypal.com => D[avid ]A[. ]B[lack’s][ Web]log
[email protected] => me

…dumb me.

thanks.

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