class Admin::ArticlesController

Homepage articles. Includes XML format.

Public Instance Methods

create() click to toggle source
# File app/controllers/admin/articles_controller.rb, line 34
def create
  @article = Article.new(params[:article])

  if @article.save
    expire_cache
    flash[:notice] = 'Article was successfully created.'
    redirect_to admin_articles_url
  else
    render :new
  end
end
destroy() click to toggle source
# File app/controllers/admin/articles_controller.rb, line 58
def destroy
  expire_cache
  @article = Article.find(params[:id])
  @article.destroy
  redirect_to admin_articles_url
end
edit() click to toggle source
# File app/controllers/admin/articles_controller.rb, line 29
def edit
  @article = Article.find(params[:id])
  @article_category = ArticleCategory.find(@article.article_category_id)
end
index() click to toggle source
# File app/controllers/admin/articles_controller.rb, line 6
def index
  if params[:article_category_id].nil?
    @articles = Article.all( :order => "title")
  else
    @articles = Article.all( :conditions => ["article_category_id = ?", params[:article_category_id]], :order => "title")
    params[:article_category_id] = nil
  end
end
new() click to toggle source
# File app/controllers/admin/articles_controller.rb, line 24
def new
  @article = Article.new
  @article_category = ArticleCategory.first
end
show() click to toggle source
# File app/controllers/admin/articles_controller.rb, line 15
def show
  @article = Article.find(params[:id])

  respond_to do |format|
    format.html
    format.xml  { render :xml => @article }
  end
end
update() click to toggle source
# File app/controllers/admin/articles_controller.rb, line 46
def update
  @article = Article.find(params[:id])

  if @article.update_attributes(params[:article])
    expire_cache
    flash[:notice] = 'Article was successfully updated.'
    redirect_to admin_articles_url
  else
    render :edit
  end
end