On Wednesday, August 8, 2012 5:45:17 PM UTC-5, Mohamad El-Husseini wrote: > > OK, thanks. But why would I do this instead of just adding the extra > resource? > > resources :users > resources :owners, controller: 'users', path: 'users' >
The reason would be if you didn't want to expose the urls: /members/:id /owners/:id I.e. with those routes defined if @user is a member with ID 37 then: link_to 'click here', @user # => goes to '/members/37' link_to 'click here', user_path(@user) # => goes to '/users/37' So if you just want to be able to do the first line and don't care about the url, map the routes; if you want to exactly duplicate the second line (i.e. your original code, and what would technically have 'helpers to generate paths using a superclass instead of the subclasses') then you could use becomes as such: link_to 'click here', @user.becomes(User) # => goes to '/users/37' However, I personally think the one with user_path is more readable in this case. \Peter -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/18IyihvWIjUJ. For more options, visit https://groups.google.com/groups/opt_out.

