Generic Actions in Rails 3
yehudakatz.com
yehudakatz.com
This isn't just "Rails can do what Django does" ... it's why it can, and how that could be used to do lots of other cool stuff.
They've done a lot of refactoring, and made a ton of improvements, so I can understand a longer-than-usual development cycle, but all the hype around how great things will be, without seeing a stable release, is a little unsettling.
http://docs.djangoproject.com/en/1.1/ref/generic-views/#date...
The powerful thing about generic views -- as far as I'm concerned -- is that they're encapsulated generic logic. Things like "show an individual object" or "show objects published in December 2009" or whatever, which crop up over and over in real-world use, and which are best written once and reused over and over again.
info_dict = {
'queryset': Poll.objects.all(),
}
(r'^(?P<object_id>\d+)/$', 'django.views.generic.list_detail.object_detail', info_dict),
One (pretty simple) solution would be to use a block to pull out the object in question: match "/:id" => object_detail {|params| Poll.find(params[:id]) }
Rails 3, with its ActiveRelation integration, could also support a syntax similar to the QuerySet syntax: match "/:id" => object_detail(Poll.all)
where Rails would internally take the Relation from Poll.all and do @relation.where(:id => params[:id]). To be honest, while the newly available syntax is nice, lightweight block syntax is pretty nice as well.