I have a User
model that can have many Websites
. For example, I will be able to call User.websites
and it will pull up an ActiveRecord array of all of the websites that the User owns. But each website uses Single Table Inheritance (STI) and a type
column that will determine the type of the website, like commercial, advertising, or forum. My problem is, that I was to make a case/when statement that runs a function if the the User has a website that is of a certain type. for example:
@user = User.first
case @user.websites
when includes?(Commercial)
'This user has a commercial website'
when includes?(Forum)
'This user has a forum website'
when include?(Ad)
'This user has a advertisement website'
end
Does anyone have a clue on the best way to do such a thing?
@user
makes no sense at all – Joe Half Faceuser
has more, that 1 type of a website inuser.websites
? – Andrey Deineko