Two pages for the same resource - ActiveAdmin

前端 未结 2 543
轻奢々
轻奢々 2020-12-05 07:35

Currently I have User model, which is registered in user.rb as a new resource for ActiveAdmin. Generated page displays all users with scopes (

2条回答
  •  一整个雨季
    2020-12-05 07:56

    you could use a parameter to distinguish the cases and render different actions depending on the parameter:

    link_to users_path(:kind => 'waiting')
    

    and in the users_controller.rb

    def index
      if params[:kind]=='waiting'
        @users= Users.where(:waiting => true)
        render :action => 'waiting' and return
      else
        # do your other stuff
      end
    end
    

    then put your new, different page (partial) in app/views/users/waiting.html.erb

    If you want to use a different layout for this page add the layout parameter to render:

    render :action => 'waiting', :layout => 'other_layout' and return
    

提交回复
热议问题