ActiveScaffold: Nested scaffold on a view with conditions for collection

ActiveScaffold is nice to get fastest results in short time but is a pain-on-ass if you try to made more.

In my case, I needed to show in a list some type of documents filtered by the conditions_for_collection method.

  1. def conditions_for_collection
  2. ['type_document_id in (?)', [12]] #you mean hardcode. I use a number but you can use a variable.
  3. end

It's works fine, but If you would like to have access to a nested scaffold and be able to see all related document without filtering them, the things go wrong.
I've solved this issue asking if we are in a nested scaffold.

  1. def conditions_for_collection
  2. unless !params[:nested].nil?
  3. ['type_document_id in (?)', [12]]
  4. end
  5. end

It Works now! I hope you enjoy.