I have a Project model which has a setting for Android device and a setting for an Apple Device.
Android setting takes in an api_key wheres Apple Device takes in a password and a certificate.
Intially I had Project has_one Android_Setting and one Apple_Setting
But now I am trying to use polymorphism
class Setting < ActiveRecord::Base
belongs_to :project
belongs_to :device_setting,polymorphic: true
end
and Project has_many :settings.
Device_Setting_Type could be AppleSetting or AndroidSetting.
Now my question is can I get the AppleSetting from the project?
Currently I am using this
project.settings.where(:device_setting_type=>"AppleSetting").first.device_setting.cert.path