On Miércoles, 30 de Diciembre de 2009 15:03:15 Edward escribió:
> 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.

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.

-- 
Sergio Cambra .:: entreCables S.L. ::.
Mariana Pineda 23, 50.018 Zaragoza
T) 902 021 404 F) 976 52 98 07 E) [email protected]

--

You received this message because you are subscribed to the Google Groups 
"ActiveScaffold : Ruby on Rails plugin" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/activescaffold?hl=en.


Reply via email to