Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 3 Routing

I have a community_users model that I route in the following way:

resources :communities do
  resources :users
end

This creates the route /communities/:id/users/.

I'd like to configure this route so that only the name of the community with the corresponding :id is shown.

In other words, if a community has an id of '1' and the name 'rails-lovers' - the route would read:

/rails-lovers

and not:

/communities/1/users/
like image 637
neon Avatar asked Feb 01 '26 19:02

neon


1 Answers

You might want to check out the gem friendly_id

That will give you the clean URLs you are looking for.

like image 156
codinguser Avatar answered Feb 04 '26 08:02

codinguser



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!