How do I create the Controller for a Single Table Inheritance in Rails?
        Posted  
        
            by Angela
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Angela
        
        
        
        Published on 2010-05-27T02:16:49Z
        Indexed on 
            2010/05/27
            2:21 UTC
        
        
        Read the original article
        Hit count: 278
        
ruby-on-rails
|single-table-inheritance
I am setting up the Single Table Inheritance, using ContactEvent as the Model that ContactEmail, ContactLetter, and ContactCall will all inherit.
But I'm stumped on how to create the routing and the controller.
For example, let's say I want to create a new ContactEvent with type Email.
I would like a way to do the following:
new_contact_event_path(contact, email)
This would take the instance from Contact model and from Email model.
Inside, I would imagine the contact_event_controller would need to know...
   @contact_event.type = (params[:email]) # get the type based on what was passed in?
   @contact_event.event_id = (params[:email]) #get the id for the correct class, in this case Email.id
Just not sure how this works....
© Stack Overflow or respective owner