Simple rails routing / url question

Posted by justinbach on Stack Overflow See other posts from Stack Overflow or by justinbach
Published on 2010-04-30T23:00:47Z Indexed on 2010/04/30 23:07 UTC
Read the original article Hit count: 176

Filed under:
|
|

I'm using Ryan Bates' nifty authentication in my application for user signup and login. Each user has_many :widgets, but I'd like to allow users to browse other users' widgets. I'm thinking that a url scheme like /username/widgets/widget_id would make a lot of sense--it would keep all widget-related code in the same place (the widgets controller). However, I'm not sure how to use this style of URL in my app.

Right now my codebase is such that it permits logged-in users to browse only their own widgets, which live at /widgets/widget_id. What changes would I need to make to routes.rb, my models classes, and any place where links to a given widget are needed?

I've done Rails work before but am a newb when it comes to more complicated routing, etc, so I'd appreciate any feedback. Thanks for your consideration!

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about routing