http://github.com/sam/dm-more/tree/6626728cec9fdde4d0b2005494c3bed74159fa30/dm-is-viewable
I wrote a gem called dm-is-viewable which works like the default named scopes but you can register them on the fly. Since they are all registered by a name (symbol | string) they are great for displaying the canned queries via hyperlinks and then retrieving the query by name. <% User.views.each do |scope_name,query| %> <a href="/users/sort/<%= scope_name %>">Sort by <%= scope_name %></ a> <% end %> then in users: def sort display User.view(params[:scop_name]) end On Dec 9, 6:43 pm, Tyler Hunt <[email protected]> wrote: > On Dec 9, 2008, at 9:17 PM, Justin Reagor wrote: > > > As for scoping contexts, such as AR's named_scopes... does DM have > > an equal or greater equivalent? It's something I use the most now at > > my day job, since building advanced queries seems to be easier using > > them. > > Fromhttp://datamapper.org/doku.php? > id=docs:finders#scopes_and_chaining: > > > Since DataMapper only executes finders when a kicker method is > > called, a call to all or first can be chained together to further > > build a query to the data-store > > So by simply defining class methods that return queries, you have the > equivalent of named scopes. > > Tyler > > smime.p7s > 3KViewDownload --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "DataMapper" 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/datamapper?hl=en -~----------~----~----~----~------~----~------~--~---
