mercredi 24 octobre 2018

has_many realtion in ruby on rails

I need to update a rails model,

has_many :unblocked_items, class_name: 'IncidentItem', 
           conditions: ['incident_items.item_type_id in (?) AND (incident_blocking_file_id IS NULL OR incident_blocking_files.way = ?)', IncidentItemType.blockable, BlockingWay.unblock],
           include: :incident_blocking_file
  has_many :blocked_items, class_name: 'IncidentItem',
           conditions: ['incident_items.item_type_id in (?) AND (incident_blocking_file_id IS NOT NULL AND (incident_blocking_files.way <> ? OR incident_blocking_files.way IS NULL))', IncidentItemType.blockable, BlockingWay.unblock],
           include: :incident_blocking_file

Get the following error Unknown key: :conditions. Valid keys are: :class_name, :anonymous_class, :foreign_key, :validate, :autosave, :table_name, :before_add, :after_add, :before_remove, :after_remove, :extend, :primary_key, :dependent, :as, :through, :source, :source_type, :inverse_of, :counter_cache, :join_table, :foreign_type (ArgumentError)

There is an easy way for making this change

Aucun commentaire:

Enregistrer un commentaire