Forum: Ruby on Rails Rails routes question

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Skaurus (Guest)
on 2009-04-06 15:21
(Received via mailing list)
Hello people :)

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 :)

Can I possibly do that?

Thank in advance!
Schalk N. (Guest)
on 2009-04-06 16:19
(Received via mailing list)
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'

Skaurus (Guest)
on 2009-04-06 16:28
(Received via mailing list)
On 6 апр, 16:18, Schalk N. <removed_email_address@domain.invalid> wrote:
> Schalk

So for scaffold-generated resourse I have to create seven routes :(
Skaurus (Guest)
on 2009-04-07 03:04
(Received via mailing list)
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 =>

Maybe some another way?
Skaurus (Guest)
on 2009-04-07 03:22
(Received via mailing list)
form_for(@post) breaks too.
This topic is locked and can not be replied to.