STI and Controller Design

Hi,

I have a question about single table inheritance and controllers. Lets
start to talk about my domain. There are two parent models in my
system, they and their children are;
class Vehicle < ActiveRecord::Base

attr_accessible :name, :model, :engine, :fuel_type …
validates …
has_many :tires
end

            class  Car < Vehicle
                      attr_accessible :car_type, :speed .....
                      validates ....................
             end
             class  Truck < Vehicle

attr_accessible :load_volume, :number_of_tires …
validates …
end

             class Tire < ActiveRecord::Base
                      attr_accessible :diameter, :material ......
                      validates ....................
                     belongs_to : vehicle
             end

            class  WinterTire < Tire
                      attr_accessible :winter_tire_type....
                      validates ....................
             end
             class  SummerTire < Tire
                      attr_accessible :summer_tire_type....
                      validates ....................
             end

To create restful controllers for these classes I choose generating
parent controllers so;
class Vehicles < ApplicationController
methods
end
class Tires < ApplicationController
methods
end

But I end up with a confusion how to use same controllers for creating
different type of child objects. Is my choice feasible or creating
seperate controllers is more suitable? But doesn’t that mean a
conflict with DRY style?
Thank you…
Rushen

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs