Rails routes question

Hello people :slight_smile:

I'm bad in English, so i'll be short. It newbie question, I think)

In my application I has users, which :has_many => posts. In routes.rb I can with ease create routes for posts like /:user_id/posts/..., but I wish to have something like /posts/:user_id/... instead. And use map.resources syntax to be one-liner, of course :slight_smile:

Can I possibly do that?

Thank in advance!

Hi there,

I have article display set-up on my side as follows: map.article 'article/show/:permalink', :controller => 'article', :action => 'show'

So you might be looking for something like this: map.posts '/posts/:user_id', :controller => 'posts', :action =< 'show'

HTH, Schalk

Skaurus wrote:

So for scaffold-generated resourse I have to create seven routes :frowning:

And url-generation for this routes a pretty ugly in views: instead of show_post_path I write now show_post_url(:user_id => post.author_id, :post_id => post.id)

Maybe some another way?

form_for(@post) breaks too.