0

I have 2 tables: campus (has_one) and notification (belongs_to)

I want to setup my routes so the index url uses the following format: /campusname/notifications

=> campusname is an unique value

With the nested routes my url always has an id. /campus/:campu_id/notifications

Currently my routes.rb looks like this:

  shallow do
    resources :campus do
      resources :notifications
    end
  end

How can I get rid of that id and use the campusname instead?

And more importantly how do I edit my controller to show the right notifications for every campus? Can somebody point me in the right direction?

Christoph
  • 1,347
  • 2
  • 19
  • 36

1 Answers1

0

It seems that your route is working correctly, you just want to make it more user friendly. One option would be to use the FriendlyId gem

FriendlyId allows you to allows you to use human friendly strings instead of ids, for example:

http://example.com/states/washington

instead of:

http://example.com/states/4323454
Tom Kadwill
  • 1,448
  • 3
  • 15
  • 21