Имеется сгенерённый скаффолдом список постов, пытаюсь добавить авторизацию. Вручную создал views/posts/login.html.erb, добавил в контроллер before_filter :authorize; login; authorize.
Получил... бесконечный цикл при попытке захода в authorize.
The webpage at http://localhost:3000/posts/login has resulted in too many redirects. ...
Помогите найти косяк.
class PostsController < ApplicationController
  before_filter :authorize, :except => [:login]
  def login
    session[:user_id] = nil
    if request.post?
      user = User.authenticate(params[:name], params[:password])
      if user
        session[:user_id] = user.id
        redirect_to(:action => "index" )
      else
        flash.now[:notice] = "Invalid user/password combination"
      end
    end
  end
  # GET /posts
  # GET /posts.xml
  def index
    @posts = Post.all
    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @posts }
    end
  end
  # GET /posts/new
  # GET /posts/new.xml
  def new
    @post = Post.new
    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @post }
    end
  end
  private
  def authorize
    unless User.find_by_id(session[:user_id])
      flash[:notice] = "Please log in"
      redirect_to :action => :login
    end
  end
endp.s. update, edit, destroy вырезал здесь за ненадобностью их показа.

