You seem too embarrassed. It seems you are trying to see if api_key and active_days exist, and if not, get it from somewhere else.
Here's the right way to do this, assuming api_key and active_days are the columns in your table:
class Setting < ActiveRecord::Base
belongs_to :settable, :polymorphic => true
def api_key
super || settable.next_link.usable_setting.api_key
end
def active_days
super || settable.next_link.usable_setting.active_days
end
end
You can reorganize it a bit to maintain clarity and remove duplication.
class Setting < ActiveRecord::Base
belongs_to :settable, :polymorphic => true
def api_key
super || next_usable_setting.api_key
end
def active_days
super || next_usable_setting.active_days
end
private
def next_usable_setting
settable.next_link.usable_setting
end
end
, - api_key/active_days, . Otehrwise, usable_setting next_link. api_key/active_days, , usable_setting next_link. Etc.