I don't know how many types you have, but I just used separate controllers and views for different types in the past. Thus, you are not creating a new object of the base class and you are not trying to set the type, you are simply using a model that inherits from the base class. Each new / edit page for your resources can display a shared partial in the form_for block. Partial will contain your file field.
Thus, when the form is submitted, it will return to the correct controller, calling the correct resource. New, and everything is in order.
Of course, the drawback is more files and any page that you link to "add a new file", you need to add several links, such as "add a new type of this file", "add a new file type", etc.
As for setting the type in the form, I'm not sure if this works, I doubt it, but just try (let us know). You can make this type drop down select_tag, and when changing, use Javascript to change the location of the action on the form.
Edited and added the main work around
Not that I liked this solution, and I doubt that it is by no means the best, but if you really do not need separate controllers and you need to make it work, you can do something like this:
class XmlFile < ActiveRecord::Base end class XmlFileTypeA < XmlFile end class XmlFileTypeB < XmlFile end def create
tsdbrown
source share