I have 3 Models
class Audio
end
class Album
end
class Movie
end
I want to have validation in Audio model.That while creating Audio the server should validate that the audio is linked with the album or movie or both. But both the fields selecting models in the from shouldn't be empty while submit.
Album should be linked with another type, lets say "Media". This allows you to have a field on "Media" which can be either "movie" or "audio".
Take a look at classy_enum on how to enforce the types: https://github.com/beerlington/classy_enum