blacklist_controller.rb

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

RB
51
字号
class Admin::BlacklistController < Admin::BaseController  def index    list    render_action 'list'  end  def list    @blacklist_patterns = BlacklistPattern.find :all  end  def show    @blacklist_pattern = BlacklistPattern.find(params[:id])  end  def new    @blacklist_pattern = BlacklistPattern.new    if params[:blacklist_pattern].has_key?('type')      @blacklist_pattern = case params[:blacklist_pattern][:type]        when "StringPattern": StringPattern.new        when "RegexPattern": RegexPattern.new      end    end rescue nil    @blacklist_pattern.attributes = params[:blacklist_pattern]    if request.post? and @blacklist_pattern.save      flash[:notice] = 'BlacklistPattern was successfully created.'      redirect_to :action => 'list'    end  end  def edit    @blacklist_pattern = BlacklistPattern.find(params[:id])    @blacklist_pattern.attributes = params[:blacklist_pattern]    if request.post? and @blacklist_pattern.save      flash[:notice] = 'BlacklistPattern was successfully updated.'      redirect_to :action => 'list'    end  end  def destroy    @blacklist_pattern = BlacklistPattern.find(params[:id])    if request.post?      @blacklist_pattern.destroy      redirect_to :action => 'list'    end  endend

⌨️ 快捷键说明

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