ballalama3_app/app/controllers/admin/article_authors_controller.rb
Nicolas Bally bc774b8159 initial
2016-12-01 10:54:16 +01:00

71 lines
1.1 KiB
Ruby

# -*- 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