I have a model called User, and a controller called ManagersController. Some users are managers as marked by a field (role = “manager”). I have a more or less standard REST CRUD but the _form template ended up looking like this:
= form_for(@user, :url => @user.new_record? ? managers_url : manager_url(@user))
I have some very similar cases in other forms and I’m sure I’m not the first one to encounter this. Is there a way to generate the proper URL out of @user without having the ternary operator in there?
The method that does the logic you’re describing is
polymorphic_urland it cannot do what you suggest.You might want to make your own helper method for this, or create a subclass that is actually called “Manager”.
Which one you choose depends on details of your application which I cannot help you with.