4 ms·
I hope I showed that those sorts of things are quite possible using the same basic techniques that I showed for the redirection and rendering generic actions. T
by wycats 17y ago
I hope I showed that those sorts of things are quite possible using the same basic techniques that I showed for the redirection and rendering generic actions. Thanks for the feedback :)
- ubernostrum 17y agoWell, it may just be that I don't know enough about Rails, but how do you do that sort of thing? For example, what's the equivalent data structure to a QuerySet that you'd pass around as an argument?
- wycats 17y agoThere are two ways I can think of to achieve a similar effect. Let's use this example from the Django docs: 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.