class ChaptersController < ApplicationController

  def list
    @book = Book.find(params[:id])
    @chapters = Chapter.find(:all, 
                            :conditions => ["book_id = %d", params[:id]],
                            :order => "position") 
  end

  def move
    if ["move_lower","move_higher","move_to_top",
        "move_to_bottom"].include?(params[:method]) \
          and params[:ch_id] =~ /^\d+$/
      Chapter.find(params[:ch_id]).send(params[:method])
    end
    redirect_to(:action => "list", :id => params[:id])
  end
end