Hi, here is a model code:
module Spree
class Address < ActiveRecord::Base
belongs_to :country
belongs_to :state

has_many :shipments

validates :firstname, :lastname, :address1, :city, :zipcode, :country,
:phone, :presence => true
validate :state_validate

attr_accessible :firstname, :lastname, :address1, :address2,
:city, :zipcode, :country_id, :state_id,
:country, :state, :phone, :state_name,
:company, :alternative_phone

What are the guides to override *validates*?
For example, I don't want *zipcode* to be validated.

--

Search Discussions

  • Ryan Bigg at Jan 20, 2013 at 10:44 pm
    Put this code inside a decorator:

    Spree::Address.class_eval do
    _validators.reject! { |key, _| key == :zipcode }
    end

    That will reject all the validations around zipcode.

    On Sun, Jan 20, 2013 at 4:18 AM, Serega Sheypak wrote:

    Hi, here is a model code:
    module Spree
    class Address < ActiveRecord::Base
    belongs_to :country
    belongs_to :state

    has_many :shipments

    validates :firstname, :lastname, :address1, :city, :zipcode, :country,
    :phone, :presence => true
    validate :state_validate

    attr_accessible :firstname, :lastname, :address1, :address2,
    :city, :zipcode, :country_id, :state_id,
    :country, :state, :phone, :state_name,
    :company, :alternative_phone

    What are the guides to override *validates*?
    For example, I don't want *zipcode* to be validated.

    --

    --

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupspree-user @
categoriesrubyonrails
postedJan 19, '13 at 5:18p
activeJan 20, '13 at 10:44p
posts2
users2
websitespreecommerce.com
irc#RubyOnRails

2 users in discussion

Ryan Bigg: 1 post Serega Sheypak: 1 post

People

Translate

site design / logo © 2022 Grokbase