# -*- encoding : utf-8 -*-

class Admin::ArticleAuthorsController < ApplicationController
  layout "admin"
  before_filter :auth_admin

  def index
    @article_authors = ArticleAuthor.order(:name).all

   
  end

  def show
    @article_author = ArticleAuthor.find(params[:id])

  end

  def new
    
    
		@article_author = ArticleAuthor.new
    

  end

 

  def edit
  
    
    @article_author = ArticleAuthor.find(params[:id])
  end

  def create
    @article_author = ArticleAuthor.new(params.require(:article_author).permit!)


    if @article_author.save
     @article_authors = ArticleAuthor.order(:name).all
      
    else
      render action: "new"
 
    end

  end


  def update
    @article_author = ArticleAuthor.find(params[:id])


    if @article_author.update_attributes(params.require(:article_author).permit!)
      
       @article_authors = ArticleAuthor.order(:name).all
    else
     render action: "edit" 
      
    end
      
  end


  def destroy
    @article_author = ArticleAuthor.find(params[:id])
    @article_author.destroy
    
    
  end
end