Forum: Ruby on Rails Rails routes question

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
40448fd80f5ca8b95db5f107c1a6372b?d=identicon&s=25 Skaurus (Guest)
on 2009-04-06 13: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!
44391f94143d129bdfdcd8b52aa51674?d=identicon&s=25 Schalk Neethling (Guest)
on 2009-04-06 14: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'

HTH,
Schalk
40448fd80f5ca8b95db5f107c1a6372b?d=identicon&s=25 Skaurus (Guest)
on 2009-04-06 14:28
(Received via mailing list)
On 6 апр, 16:18, Schalk Neethling <volume4.sch...@gmail.com> wrote:
> Schalk
>

So for scaffold-generated resourse I have to create seven routes :(
40448fd80f5ca8b95db5f107c1a6372b?d=identicon&s=25 Skaurus (Guest)
on 2009-04-07 01: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 => post.id)

Maybe some another way?
40448fd80f5ca8b95db5f107c1a6372b?d=identicon&s=25 Skaurus (Guest)
on 2009-04-07 01:22
(Received via mailing list)
form_for(@post) breaks too.
This topic is locked and can not be replied to.