I have a controller and every method of it starts with the following code:
@user = UserData.find_by_login(session[:cuser])
if @user == nil
redirect_to(:controller=> 'user_data', :action=> 'login')
return
end
I’m just wondering if it is possible to avoid code duplication in this case ?
Yes, use a before_filter