active admin常用配置

ActiveAdmin.register Post do

  permit_params :title, :content, :deadline, :status

  menu parent: "论坛管理", label: "帖子管理", :priority => 2
  config.per_page = 20
  config.sort_order = "id_asc"

  index :title=>"帖子管理" do
    selectable_column
    id_column
    column "标题", :title
  
    column "提交日期" do |f|
      f.deadline ? f.deadline.strftime('%Y-%m-%d %H:%M:%S') : ""
    end
   
    column "用户" do |f|
      link_to f.user.id, admin_user_path(f.user) if f.user
    end
    column "分类" do |f|
      f.label ? f.label.name : ""
    end
    column "创建时间", :sortable=>:created_at do |f|
      f.created_at.strftime('%Y-%m-%d %H:%M:%S')
    end

    actions
  end

  form do |f|
    f.inputs "Post详情" do
      f.input :title, :label => "标题"
    end
    f.inputs "额外信息" do
      f.input :content, :label => "标题"
    end
    f.actions
  end

  show :title=>:title do
    attributes_table do
      row "操作" do
        link_to("设置置顶", set_stick_admin_post_path(post.id)) + "  " + link_to("取消置顶", clear_stick_admin_post_path(post.id))
      end
    end
  end

  #route当中无需任何配置
  member_action :set_stick do
    post = Post.find(params[:id])
    post.update_attribute :status, Setting.posts.status_stick
    redirect_to admin_post_path(params[:id])
  end

  member_action :clear_stick do
    post = Post.find(params[:id])
    post.update_attribute :status, Setting.posts.status_none
    redirect_to admin_post_path(params[:id])
  end

  
 controller do
    def update
      update! do |f|
        puts permitted_params[:citrine][:count]
        f.html {redirect_to root_path}
      end
    end
  end
 
  

 


end

 

转载于:https://www.cnblogs.com/znsongshu/p/10381642.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值