I have resolved this problem.
I had defined routes in this order:
map.resources :comments
map.resources :posts, :has_many => :comments
Changing order of these two lines is enough to do what I need
- order helper creates /post/:post_id/comments link when params
[:post_id] exists
and /comments when params[:post_id] is nil.
Petr