Wrap text
Report abuse
|
|
class Admin::NewsController < ApplicationController
layout "admin"
before_filter :admin_required
def index
@articles = NewsArticle.all
end
def edit
@article = NewsArticle.find(params[:id])
end
def update
@article = NewsArticle.find(params[:id])
if @article.update_attributes(params[:news_article])
redirect_to :action => :index
else
render :action => :edit
end
end
def new
@article = NewsArticle.new
end
def create
@article = NewsArticle.new(params[:news_article])
if @article.save
redirect_to :action => :index
else
render :action => :new
end
end
def destroy
NewsArticle.destroy(params[:id])
redirect_to :action => :index
end
end
|