Say that there''s a piece of functionality I want to call everytime the controller is invoked, regardless of what action I am calling. Where do I put that, exactly? Can I do that? -- Posted via http://www.ruby-forum.com/.
Duane wrote:> Say that there''s a piece of functionality I want to call everytime the > controller is invoked, regardless of what action I am calling. Where do > I put that, exactly? > Can I do that?Take a look at before_filter. You can specify which method you want called before any action is called. You can also customize which actions your filter will apply to. Jeff softiesonrails.com -- Posted via http://www.ruby-forum.com/.
D''oh! I''m already using before_filter for my authorization stuff anyway. Should ahve thought of that. Thanks Jeff! Jeff Cohen wrote:> Duane wrote: >> Say that there''s a piece of functionality I want to call everytime the >> controller is invoked, regardless of what action I am calling. Where do >> I put that, exactly? >> Can I do that? > > Take a look at before_filter. You can specify which method you want > called before any action is called. You can also customize which > actions your filter will apply to. > > Jeff > softiesonrails.com-- Posted via http://www.ruby-forum.com/.
Jeff Cohen wrote:> Duane wrote: >> Say that there''s a piece of functionality I want to call everytime the >> controller is invoked, regardless of what action I am calling. Where do >> I put that, exactly? >> Can I do that? > > Take a look at before_filter. You can specify which method you want > called before any action is called. You can also customize which > actions your filter will apply to. > > Jeff > softiesonrails.comclass MyController < ApplicationController before_filter :require_login, :except => [:signup, :about] def require_login redirect_to :action => ''signup'' unless session[:user] end end -- Posted via http://www.ruby-forum.com/.