On Jun 29, 1:58 am, Xavier Lange <[email protected]> wrote:
> 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?

It makes sense to me, and I see no problems with it, so it's now
supported in the master branch (http://github.com/jeremyevans/sequel/
commit/fc3a547e1c84f24680285799a71344b8fffc65f7).

Jeremy
--~--~---------~--~----~------------~-------~--~----~
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