I'm using the Single Table Inheritance plugin and I'd like to allow
the sti key to be settable when creating.

For example, with sti_key :kind, Person.create(:kind => "Manager")
will insert with kind set to "Person".

My proposed change to plugins/single_table_inheritance.rb

      module InstanceMethods
        # Set the sti_key column to the name of the model.
        def before_create
          return false if super == false
          send("#{model.sti_key}=", model.name.to_s) if send("#
{model.sti_key}").nil? # this line
        end
      end

Does that make sense? Can you see any problems with it?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sequel-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to