All records in a list

2 views
Skip to first unread message

Edward

unread,
Dec 29, 2009, 3:30:41 PM12/29/09
to ActiveScaffold : Ruby on Rails plugin
Is there a way to pass the whole collection from a list to another
method in the params. I can't seem to get past @records only holding
the records per page

Thanks

Sergio Cambra .:: entreCables S.L. ::.

unread,
Dec 30, 2009, 3:18:20 AM12/30/09
to actives...@googlegroups.com

I can't understand what you are trying to do. Please, explain in more detail

--
Sergio Cambra .:: entreCables S.L. ::.
Mariana Pineda 23, 50.018 Zaragoza
T) 902 021 404 F) 976 52 98 07 E) ser...@entrecables.com

Edward

unread,
Dec 30, 2009, 9:03:15 AM12/30/09
to ActiveScaffold : Ruby on Rails plugin
Sorry. I have a list that contains 1000 records, but only shows 25
per page. I would like to put a link on the page to send all 1000
records to another controller so I can run a report on all the
records.

When i override the list.html.erb or _list.html.erb files the instance
var @records only contains the 25 records showing on the current
page. Is there an instance variable that contains all 1000 records,
or is there a method in my controller to build a link on the table to
pass all 1000 records.

Or... Is there a way to assign the finder conditions that AS uses to
my own variable so I can reuse it.

Basically I would like to do something like this:

link_to "Report", :controller => 'reports', :action =>
'build_report', :records => @records

I would like @records to point to all 1000 records, but right now it
only has the 25 records from the current page being diplayed in the
list.

Thanks

Sergio Cambra .:: entreCables S.L. ::.

unread,
Dec 30, 2009, 10:16:06 AM12/30/09
to actives...@googlegroups.com

It's not related to AS, you want to build an URL in rails, you don't want to
change the records shown by AS. If you need to set more variables in the list
action, you can override do_list method, calling super in order not to lose AS
code, or set a before_filter to some actions.

You can load all records in rails, and pass all ids as argument in the url,
but is a bad idea to build so long URL and to send so much data. You can get
all records you need in reports controller. Also it's better to select all
records without adding "where id IN (all id list)" to select query, it would
be slow to build, and slower to execute.

If reports controller build a report for records you pass, add another action
to build a report for all records.

I think it's more a rails issue than AS issue, it would be better to ask in a
rails list instead of a rails plugin list as this one if you have doubts about
how to do that controller. Anyway if you need some help about how to link some
AS controllers with your report controller, or how to override some AS views,
explain where you want to add that link, if there is a report model, what
associations between your models and so on.

Also you can add a report action to your controller. Report action it would
use @records = Model.all to get all records. If you want to build reports for
multiple models, set in a module and include it in some controllers. You can
use active_scaffold_config.model instead of Model if you use AS in all of those
controllers, in other case you will have to guess model from controller name
or add a method in each controller which returns the model class.

Reply all
Reply to author
Forward
0 new messages