On Viernes, 11 de Diciembre de 2009 02:50:59 mobilemike escribió: > My client is looking for a "less AJAXy" why to filter some of their > data. I've gotten it half-way there, but could use some guidance. > > class Computer < ActiveRecord::Base > belongs_to :owner > end > > class Owner < ActiveRecord::Base > has_many :computers > end > > map.resources :owners, :has_many => :computers, :active_scaffold => > true > > So, /owners shows each owner, and I was able to nest the computers as > a link off each owner. They didn't care for how AJAXy this is, with > expanding data inlace. What the client wanted was just a page for each > owner, something to link directly to. I see that /owners/1/computers > does restrict the list to only the associated records, so I'm almost > al the way there. There's two things I can't figure out. > > 1) What's the best way to customize the page title? In > _list_header.html.erb the title is displayed as: > <h2><%= active_scaffold_config.list.user.label %></h2> > How can I modify this to just say "Computers" on the regular / > computers page, and something like "Mike's Computers" on a nested / > owners/1/computers page?
You can try to set the label with a before_filter in your controller. > > 2) How can I tell Active Scaffold to hide the Owners column when in > this situation? It's awfully redundant. Again, add a before_filter to remove column from list columns when :owner_id is set, and add it when :owner_id is nil. > > 3) (bonus) Is this the best way to go about proving this > functionality? Should I be going down a different ally? You can get something like above using nested from ActiveScaffold. Now you are using filtering (ActiveScaffold filter from params if some param is a column). I'm working to support nested routes for nested scaffolds to stop using render_component, it's in experimental branch To try using nested from ActiveScaffold with master branch, try with an URL like owners/1/nested?associations=computers Also, you can use nested links generated by ActiveScaffold, or add them with config.nested.add_link, and disable AJAX with page => true (columns[:computers].link.page = true, or :page => true option in nested.add_link) > > -- > > 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. -- 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.
