I'm using STI with a Rails 3.2 app. I want to force Rails to use the superclass name in link_to
helpers (or any where else when it's generating paths) and not the subclass name.
So, <%= link_to current_user.name, current_user %>
produces /:class_name/:id
(class name can be "Moderator," "Member," etc...).
I would like it to produce /users/:id
, where users
does not change to the name of the subclass. I know I can change current_user
to user_path(current_user)
, but I prefer to use the shortcut, letting Rails figure it out.
Is this possible?
I think you should define url helpers, something like this
def moderator_url record
user_url record
end
Or just use aliases
alias :moderator_url :user_url
This is code which rails use for url generation when you pass a record as a option