[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

before_filter

misiek

1/18/2006 10:45:00 PM

I think that before_filter is like sessions with PHP
but I have no ideas ho to use it.

I need

I know that I need to put that to ...

class ApplicationController < ActionController::Base
before_filter :super_user_session

def super_user_session
@id = @params['id']
@super_id = @params['super_id']
end
end

so I am going to

def sign_in
@user = User.find(:first, :conditions => "login = '" +
@params['user']['login'] + "' and passwd = '" +
@params['user']['passwd'] + "'")

redirect_to(:controller => "application", :action =>
"super_user_session", :id => @user, :super_id => @user)

end

from sign_in to super_user_session to set up the variables
but what now ???
1 Answer

Marcin Mielzynski

1/18/2006 11:45:00 PM

0

misiek wrote:
> I think that before_filter is like sessions with PHP
> but I have no ideas ho to use it.
>

Sessions in Rails act like sessions in other frameworks (they are simply
hashes), so You can:

unless session[:id]
session[:id]='blah'
# blah
end


Filters are used to intercept a control (before/after).

Remember, rails controller instances are created every request call, so
You can use instance variables only within a single request scope (views
have access to them of course).

lopex