categories_controller.rb

来自「用ruby on rails写的一个博客程序,还不错..ruby on rail」· RB 代码 · 共 65 行

RB
65
字号
class Admin::CategoriesController < Admin::BaseController  def index    list    render_action 'list'  end  def list    @categories = Category.find(:all, :order => :position)  end  def show    @category = Category.find(params[:id])  end  def new    @category = Category.new(params[:category])    if request.post? and @category.save      flash[:notice] = 'Category was successfully created.'    else      flash[:error] = 'Category could not be created.'    end    redirect_to :action => 'list'  end  def edit    @category = Category.find(params[:id])    @category.attributes = params[:category]    if request.post? and @category.save      flash[:notice] = 'Category was successfully updated.'      redirect_to :action => 'list'    end  end  def destroy    @category = Category.find(params[:id])    if request.post?      @category.destroy      redirect_to :action => 'list'    end  end  def order    Category.reorder(params[:category_list])    render :nothing => true  end  def asort    Category.reorder_alpha    category_container  end  def category_container    @categories = Category.find(:all, :order => :position)    render :partial => "categories"  end  def reorder    @categories = Category.find(:all, :order => :position)    render :layout => false  endend

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?