Administrate: resources is overriden on the index page

Created on 6 Feb 2016  路  4Comments  路  Source: thoughtbot/administrate

Hello,

Trying the last version; I am using a custom request to get the @resources to display. It seems I still get all my database entries.
Tou can try with something like:

module Admin
  class PagesController < Admin::ApplicationController
    def index
      super
      @resources = []
    end
  end
end

Most helpful comment

+1 critical feature. Here's how I worked around it based on what @lenart said.

See attached image content. The brown highlight is where I put a conditional. If there is an _order_ param put in the URL by administrate, then just do the usual order.apply, but if not, then use my own default ordering. (created_at desc)

image

YAAAASSSS RUBYMINE!

All 4 comments

I believe the problem is that super calls render before the @resources = []. Currently it's not really possible to easily override resources scope; you'll have to copy over the entire index action and make the necessary changes.

Just found similar discussion where they suggest to use the same approach I mentioned above.

+1 critical feature. Here's how I worked around it based on what @lenart said.

See attached image content. The brown highlight is where I put a conditional. If there is an _order_ param put in the URL by administrate, then just do the usual order.apply, but if not, then use my own default ordering. (created_at desc)

image

YAAAASSSS RUBYMINE!

Thanks for the hack!

The explanation and suggestion above is exactly right.

Was this page helpful?
0 / 5 - 0 ratings