As of spree 1.3 you can disable phone validation by overriding the `require_phone?` method

Spree::Address.class_eval do
   protected
     def require_phone?
       false
     end
end

Am 30.01.2013 um 23:34 schrieb blake@maytro.com:
I ended up resolving this issue with the following code in
app/models/address_decorator.rb:

Spree::Address.class_eval do

# Remove the requirement on :phone being present.
_validators.reject!{ |key, _| key == :phone }

_validate_callbacks.each do |callback|
callback.raw_filter.attributes.delete :phone if
callback.raw_filter.is_a?(ActiveModel::Validations::PresenceValidator)
end

end

Hope that helps!

On Monday, November 26, 2012 2:33:46 AM UTC-8, Rein Aris wrote:

_validators.reject!{ |key, _| key == :phone }
was what I tried (inside a decorator), I tried several things to remove
phone from the validator. None worked so it's hard to give you my best try
because I wasn't able to succeed.

Op 26-11-2012 11:30, Ryan Bigg schreef:

Was this exactly the code you tried though? I need to be sure for when I
attempt to reproduce this issue on my machine.



On 26/11/2012, at 20:38, Rein Aris <in...@reinaris.nl <javascript:>>
wrote:

I tried (in a decorator) something like:

-------------------------------------------
_validators.reject!{ |key, _| key == :phone }
-------------------------------------------

And:

-------------------------------------------
_validators.reject!{ |key, _| key == :phone }

_validate_callbacks.reject! do |callback|
callback.raw_filter.attributes == [:phone]
end
-------------------------------------------

Last one fails on 'attributes', it's not known.
I can't remove phone from the _validators attribute.

Op 26-11-2012 4:56, Ryan Bigg schreef:

Do you have an example of this address_decorator that you could show us?


On Fri, Nov 23, 2012 at 8:19 PM, reinaris <in...@reinaris.nl <javascript:>
wrote:
I'd like to make the phone field not required in the checkout.
I've been testing and reading
http://stackoverflow.com/questions/7545938/how-to-remove-validation-using-instance-eval-clause-in-railsto make an address_decorator, but still no success.

Can anyone help me out with this?
--
You received this message because you are subscribed to the Google Groups
"Spree" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/spree-user/-/LlHW9qEs8UgJ.
To post to this group, send email to spree...@googlegroups.com<javascript:>
.
To unsubscribe from this group, send email to
spree-user+...@googlegroups.com <javascript:>.
For more options, visit this group at
http://groups.google.com/group/spree-user?hl=en.
--
You received this message because you are subscribed to the Google Groups
"Spree" group.
To post to this group, send email to spree...@googlegroups.com<javascript:>
.
To unsubscribe from this group, send email to
spree-user+...@googlegroups.com <javascript:>.
For more options, visit this group at
http://groups.google.com/group/spree-user?hl=en.


--
You received this message because you are subscribed to the Google Groups
"Spree" group.
To post to this group, send email to spree...@googlegroups.com<javascript:>
.
To unsubscribe from this group, send email to
spree-user+...@googlegroups.com <javascript:>.
For more options, visit this group at
http://groups.google.com/group/spree-user?hl=en.

--
You received this message because you are subscribed to the Google Groups
"Spree" group.
To post to this group, send email to spree...@googlegroups.com<javascript:>
.
To unsubscribe from this group, send email to
spree-user+...@googlegroups.com <javascript:>.
For more options, visit this group at
http://groups.google.com/group/spree-user?hl=en.

--
You received this message because you are subscribed to the Google Groups "Spree" group.
To unsubscribe from this group and stop receiving emails from it, send an email to spree-user+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to the Google Groups "Spree" group.
To unsubscribe from this group and stop receiving emails from it, send an email to spree-user+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Flyup at May 30, 2014 at 1:11 pm
    I added the following to my spree 2.2.2 site to remove phone requirement
    and it broke my site:

    Spree::Address.class_eval do
       protected
         def require_phone?
           false
         end
    end

    It only broke my production env- It worked perfectly on my development
    machine. Could there be some permission issue with this?
    On Thursday, January 31, 2013 1:37:12 PM UTC-6, laurens wrote:

    As of spree 1.3 you can disable phone validation by overriding the
    `require_phone?` method

    Spree::Address.class_eval do
    protected
    def require_phone?
    false
    end
    end

    Am 30.01.2013 um 23:34 schrieb bl...@maytro.com <javascript:>:
    I ended up resolving this issue with the following code in
    app/models/address_decorator.rb:

    Spree::Address.class_eval do

    # Remove the requirement on :phone being present.
    _validators.reject!{ |key, _| key == :phone }

    _validate_callbacks.each do |callback|
    callback.raw_filter.attributes.delete :phone if
    callback.raw_filter.is_a?(ActiveModel::Validations::PresenceValidator)
    end

    end

    Hope that helps!

    On Monday, November 26, 2012 2:33:46 AM UTC-8, Rein Aris wrote:

    _validators.reject!{ |key, _| key == :phone }
    was what I tried (inside a decorator), I tried several things to remove
    phone from the validator. None worked so it's hard to give you my best
    try
    because I wasn't able to succeed.

    Op 26-11-2012 11:30, Ryan Bigg schreef:

    Was this exactly the code you tried though? I need to be sure for when
    I
    attempt to reproduce this issue on my machine.



    On 26/11/2012, at 20:38, Rein Aris <in...@reinaris.nl <javascript:>>
    wrote:

    I tried (in a decorator) something like:

    -------------------------------------------
    _validators.reject!{ |key, _| key == :phone }
    -------------------------------------------

    And:

    -------------------------------------------
    _validators.reject!{ |key, _| key == :phone }

    _validate_callbacks.reject! do |callback|
    callback.raw_filter.attributes == [:phone]
    end
    -------------------------------------------

    Last one fails on 'attributes', it's not known.
    I can't remove phone from the _validators attribute.

    Op 26-11-2012 4:56, Ryan Bigg schreef:

    Do you have an example of this address_decorator that you could show
    us?

    On Fri, Nov 23, 2012 at 8:19 PM, reinaris <in...@reinaris.nl
    <javascript:>
    wrote:
    I'd like to make the phone field not required in the checkout.
    I've been testing and reading
    http://stackoverflow.com/questions/7545938/how-to-remove-validation-using-instance-eval-clause-in-railsto
    make an address_decorator, but still no success.
    Can anyone help me out with this?
    --
    You received this message because you are subscribed to the Google
    Groups
    "Spree" group.
    To view this discussion on the web visit
    https://groups.google.com/d/msg/spree-user/-/LlHW9qEs8UgJ.
    To post to this group, send email to spree...@googlegroups.com<javascript:>
    .
    To unsubscribe from this group, send email to
    spree-user+...@googlegroups.com <javascript:>.
    For more options, visit this group at
    http://groups.google.com/group/spree-user?hl=en.
    --
    You received this message because you are subscribed to the Google
    Groups
    "Spree" group.
    To post to this group, send email to spree...@googlegroups.com<javascript:>
    .
    To unsubscribe from this group, send email to
    spree-user+...@googlegroups.com <javascript:>.
    For more options, visit this group at
    http://groups.google.com/group/spree-user?hl=en.


    --
    You received this message because you are subscribed to the Google
    Groups
    "Spree" group.
    To post to this group, send email to spree...@googlegroups.com<javascript:>
    .
    To unsubscribe from this group, send email to
    spree-user+...@googlegroups.com <javascript:>.
    For more options, visit this group at
    http://groups.google.com/group/spree-user?hl=en.

    --
    You received this message because you are subscribed to the Google
    Groups
    "Spree" group.
    To post to this group, send email to spree...@googlegroups.com<javascript:>
    .
    To unsubscribe from this group, send email to
    spree-user+...@googlegroups.com <javascript:>.
    For more options, visit this group at
    http://groups.google.com/group/spree-user?hl=en.

    --
    You received this message because you are subscribed to the Google
    Groups "Spree" group.
    To unsubscribe from this group and stop receiving emails from it, send
    an email to spree-user+...@googlegroups.com <javascript:>.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Flyup at May 30, 2014 at 2:04 pm
    I fixed this problem in my production env. by removing 'protected' -


    On Friday, May 30, 2014 8:10:50 AM UTC-5, flyup wrote:

    I added the following to my spree 2.2.2 site to remove phone requirement
    and it broke my site:

    Spree::Address.class_eval do
    protected
    def require_phone?
    false
    end
    end

    It only broke my production env- It worked perfectly on my development
    machine. Could there be some permission issue with this?
    On Thursday, January 31, 2013 1:37:12 PM UTC-6, laurens wrote:

    As of spree 1.3 you can disable phone validation by overriding the
    `require_phone?` method

    Spree::Address.class_eval do
    protected
    def require_phone?
    false
    end
    end

    Am 30.01.2013 um 23:34 schrieb bl...@maytro.com:
    I ended up resolving this issue with the following code in
    app/models/address_decorator.rb:

    Spree::Address.class_eval do

    # Remove the requirement on :phone being present.
    _validators.reject!{ |key, _| key == :phone }

    _validate_callbacks.each do |callback|
    callback.raw_filter.attributes.delete :phone if
    callback.raw_filter.is_a?(ActiveModel::Validations::PresenceValidator)
    end

    end

    Hope that helps!

    On Monday, November 26, 2012 2:33:46 AM UTC-8, Rein Aris wrote:

    _validators.reject!{ |key, _| key == :phone }
    was what I tried (inside a decorator), I tried several things to
    remove
    phone from the validator. None worked so it's hard to give you my best
    try
    because I wasn't able to succeed.

    Op 26-11-2012 11:30, Ryan Bigg schreef:

    Was this exactly the code you tried though? I need to be sure for when
    I
    attempt to reproduce this issue on my machine.



    On 26/11/2012, at 20:38, Rein Aris <in...@reinaris.nl <javascript:>>
    wrote:

    I tried (in a decorator) something like:

    -------------------------------------------
    _validators.reject!{ |key, _| key == :phone }
    -------------------------------------------

    And:

    -------------------------------------------
    _validators.reject!{ |key, _| key == :phone }

    _validate_callbacks.reject! do |callback|
    callback.raw_filter.attributes == [:phone]
    end
    -------------------------------------------

    Last one fails on 'attributes', it's not known.
    I can't remove phone from the _validators attribute.

    Op 26-11-2012 4:56, Ryan Bigg schreef:

    Do you have an example of this address_decorator that you could show
    us?

    On Fri, Nov 23, 2012 at 8:19 PM, reinaris <in...@reinaris.nl
    <javascript:>
    wrote:
    I'd like to make the phone field not required in the checkout.
    I've been testing and reading
    http://stackoverflow.com/questions/7545938/how-to-remove-validation-using-instance-eval-clause-in-railsto
    make an address_decorator, but still no success.
    Can anyone help me out with this?
    --
    You received this message because you are subscribed to the Google
    Groups
    "Spree" group.
    To view this discussion on the web visit
    https://groups.google.com/d/msg/spree-user/-/LlHW9qEs8UgJ.
    To post to this group, send email to spree...@googlegroups.com<javascript:>
    .
    To unsubscribe from this group, send email to
    spree-user+...@googlegroups.com <javascript:>.
    For more options, visit this group at
    http://groups.google.com/group/spree-user?hl=en.
    --
    You received this message because you are subscribed to the Google
    Groups
    "Spree" group.
    To post to this group, send email to spree...@googlegroups.com<javascript:>
    .
    To unsubscribe from this group, send email to
    spree-user+...@googlegroups.com <javascript:>.
    For more options, visit this group at
    http://groups.google.com/group/spree-user?hl=en.


    --
    You received this message because you are subscribed to the Google
    Groups
    "Spree" group.
    To post to this group, send email to spree...@googlegroups.com<javascript:>
    .
    To unsubscribe from this group, send email to
    spree-user+...@googlegroups.com <javascript:>.
    For more options, visit this group at
    http://groups.google.com/group/spree-user?hl=en.

    --
    You received this message because you are subscribed to the Google
    Groups
    "Spree" group.
    To post to this group, send email to spree...@googlegroups.com<javascript:>
    .
    To unsubscribe from this group, send email to
    spree-user+...@googlegroups.com <javascript:>.
    For more options, visit this group at
    http://groups.google.com/group/spree-user?hl=en.

    --
    You received this message because you are subscribed to the Google
    Groups "Spree" group.
    To unsubscribe from this group and stop receiving emails from it, send
    an email to spree-user+...@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupspree-user @
categoriesrubyonrails
postedJan 31, '13 at 7:37p
activeMay 30, '14 at 2:04p
posts3
users2
websitespreecommerce.com
irc#RubyOnRails

2 users in discussion

Flyup: 2 posts Laurens Nienhaus: 1 post

People

Translate

site design / logo © 2022 Grokbase