In my experience setting the list of columns in a before_filter is a bit of a pain, likely too much so if you want 10 views, each with different columns. You have to do something like...
config.list.columns.add(:desired_column) unless config.list.columns.include?(:desired_column) config.list.columns.remove(:undesired_column) if config.list.columns.include?(:undesired_column) And thats only for the list view. If you want create/update/show/search to behave the same then you have to do similar things for config.create.columns, etc. You may want to consider simply having a separate active scaffold controller for each of your desired "views", where each points at the same model but has a different config.columns list. This works just fine so long as they are not rendered in the same view together. On Fri, Jan 8, 2010 at 3:43 PM, mobilemike <[email protected]> wrote: > I have a very wide table (around 50 columns with more looming every > day) and I currently only show a very smal subset in the list view. I > use AS to display data to end users, not for an admin interface. My > user community is clambering for access to different views on the > data; lists that show different subsets of columns based on tasks. > > I've had a lot of success using a before_filter to filter the rows > returned, but column filtering seems really hard right in AS. In this > post, > > http://groups.google.com/group/activescaffold/browse_thread/thread/bb6f7f1c35834d49/6933e0463a73785d?lnk=gst&q=columns#6933e0463a73785d > , > there's a snippet of code that can recursively exclude columns. I > supposed this code could be used to also add them, but it seems like > an awful lot of overhead. > > active_scaffold_config.list.columns.each { |col| > active_scaffold_config.list.columns.exclude col.name } > > I can see my app ending up with 10 or so views, and it would be much > simpler (and DRYer I think) to just explicitly set the columns > necessary for each of these views using a case statement. Has anyone > succeeded in doing this? Is there already a simple feature for doing > this that I'm overlooking? > > -- > 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]<activescaffold%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/activescaffold?hl=en. > > > >--
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.
