class Admin::AuthorsController < ApplicationController layout "admin" before_filter :auth_admin def index @authors = Author.all end def show @author = Author.find(params[:id]) end def new @author = Author.new end def edit @author = Author.find(params[:id]) end def create @author = Author.new(author_params) if @author.save @authors = Author.all else render :action => "new" end end def update @author = Author.find(params[:id]) if @author.update_attributes(author_params) else render :action => "edit" end end def destroy @author = Author.find(params[:id]) @author.destroy if @author != @current_author end private def author_params params.require(:author).permit(:name, :firstname, :username, :password, :password_confirmation, :email, :avatar) end end