maisonarbre_app/app/controllers/admin/articles_controller.rb
Nicolas Bally 1fa250e0e4 Initial
2011-07-15 12:29:09 +02:00

84 lines
991 B
Ruby

# -*- encoding : utf-8 -*-
class Admin::ArticlesController < ApplicationController
before_filter :authenticate_admin!
layout "admin"
navigation :articles
before_filter :find_articles
def index
end
def cible
render :layout => false
end
def new
@article = Article.new(:published_at => Time.now)
end
def edit
@article = Article.find(params[:id])
end
def create
@article = Article.new(params[:article])
if @article.save
flash[:notice] = "L'article à été ajouté avec succès."
self.find_articles
else
render :action => "new"
end
end
def update
@article = Article.find(params[:id])
if @article.update_attributes(params[:article])
flash[:notice] = "L'article à été modifié avec succès."
else
render :action => "edit"
end
end
def destroy
@article = Article.find(params[:id])
@article.destroy
end
protected
def find_articles
@articles = Article.all
end
end