I'm trying to validate a product form with has many through colors and sizes on a multi-step wicked wizard form using this gem enter link description here
but did not validate the step, someone have any idea how to validate related models on a wizard form? thank's
i've trying to validate through color model. but in this case scenario seems that is just possible through the product model.
class Product < ActiveRecord::Base
has_many :sizeships
has_many :sizes, through: :sizeships
has_many :colorships
has_many :colors, through: :colorships
include Wicked::Wizard::Validations
def self.wizard_steps
[
"first"
]
end
end
class Color < ActiveRecord::Base
attr_accessible :name, :hex
has_many :colorships
has_one :colorship
has_many :products, :through => :colorships
accepts_nested_attributes_for :products, :order
include Wicked::Wizard::Validations
def current_step
product.current_step
end
def wizard_steps
Product.wizard_steps
end
def color_id_validations
{
color_id: {
presence: {
presence: true }
}
}
end
end
Aucun commentaire:
Enregistrer un commentaire