user6528504
user6528504

Reputation:

rails Validate has_many through

I'm trying to validate has_many through association using the id or the validade associated method but, the log spits out!

someone have any idea how to validate a has_many through? thank's

syntax error, unexpected '[', expecting tSTRING_CONTENT or tSTRING_DBEG or tSTRING_DVAR or tSTRING_END if !halted && true && (validation_context == :[:update])

validates :image_id, :size_id, :color_id,  presence: true, :on => [  :update ]

validates_associated :images, :sizes, :colors, presence: true, :on => [  :update ]

Upvotes: 0

Views: 412

Answers (1)

Andrey Deineko
Andrey Deineko

Reputation: 52367

validates :image_id, :size_id, :color_id,      presence: true, on: :update
validates_associated :images, :sizes, :colors, presence: true, on: :update

Upvotes: 1

Related Questions