Czy istnieje sposób, aby uzyskać listę modeli, do których należy dany model w Railsach?Dostęp do asocjacji w Railsach
Na przykład:
class Project < ActiveRecord::Base
has_one :status
...
end
class Task < ActiveRecord::Base
has_one :status
...
end
class Status < ActiveRecord::Base
belongs_to :project
belongs_to :task
# this is where I want to be able to pass in an array of the associations' class
# names (to be used for checking input) rather than having to do w%{ project task }
# which leaves it open to failure if I add new associations in future
validates_inclusion_of :status_of, :in => ?
...
end
Nadzieja to sprawia, że jakiś sens!
Dokładnie tego, czego szukałem! Wielkie dzięki. –
Niesamowita odpowiedź. Spot na miejscu. – Tilendor