Patrick Aljord wrote:> Hey all,
> I have a simple session checker function in my application.rb:
>  def check_session
>      unless !session[:state].nil?
>     redirect_to :controller => ''users'', :action =>
''login''
>     end
>  end
> 
> I would like to apply that function to some actions only of my 
> ''machines''
> controller which are edit,update,create,new and destroy. I know it has
> something to do with before_filter but I''m not sure how to use it.
> 
> any idea?
> 
> thanx in advance
> 
> Pat
try:
class ApplicationController < ActionController::Base
  def check_session
   unless !session[:state].nil?
    redirect_to :controller => ''users'', :action =>
''login''
   end
end
def MachinesController < ApplicationController
   before_filter :check_session, :only => [:edit, :create, :new, 
:destroy]
end
If you only have those 4 methods in the controller thenyou can delete 
the :only part of that filter.
--jake
-- 
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---