I have something like this in one of my apps for email and cell:
validate :presence_of_email_or_cell
def presence_of_email_or_cell
errors.add("Either an email address or cell phone number is
required") if email.blank? and cell_number.blank?
end
On Sep 29, 9:34 am, "John T."
wrote:
> Thrivi
Thriving K. wrote:
> Mukund wrote:
>> Write your own validate routine instead of using the helpers.
>>
>> On Sep 29, 11:32�am, "Thriving K."
>
>
> Is there any guideline for that... please.
www.google.com
--
Posted via http://www.ruby-forum.com/.
--~--~-~--~~~---
Hi
> i want it to appear only one message tell that
> phone number or mobile number can't be blank, how could i do that.
You can do like
def validate
validate_phone_and_mobile([mobile_number,phone_number])
end
def validate_phone_and_mobile(numbers)
errors.add_to_base("
Mukund wrote:
> Write your own validate routine instead of using the helpers.
>
> On Sep 29, 11:32�am, "Thriving K."
Is there any guideline for that... please.
--
Posted via http://www.ruby-forum.com/.
--~--~-~--~~~---~--~~
You received this message because yo
Write your own validate routine instead of using the helpers.
On Sep 29, 11:32 am, "Thriving K."
wrote:
> I found another problem when i use this code
>
> validates_presence_of :mobile_number,:if => :phone_number_blank_check
> validates_presence_of :phone_number,:if => :mobile_number_blank_check
I found another problem when i use this code
validates_presence_of :mobile_number,:if => :phone_number_blank_check
validates_presence_of :phone_number,:if => :mobile_number_blank_check
def phone_number_blank_check
self.phone_number.blank?
end
def mobile_number_blank_check
self.m
Thank you
--
Posted via http://www.ruby-forum.com/.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe
Hi
What I understood is you have to check presence of phone number and
mobile number But not at the same time Right? If so please try the
following Assuming you have the fields phone_number and mobile_number
validates_presence_of :mobile_number,:if => :phone_number_blank_check
validates_p
i don't understand... could you please explain more
also , i thought i use the wrong word.
There are two field like this
Mobile Phone Phone .
validate if mobile phone Or phone is filled , not neccessary to field
both, but filled at least one.
--
Posted vi
Hi
As an example
validates_format_of :phone_number,:allow_nil => true,:with => /regex
here/
Sijo
--
Posted via http://www.ruby-forum.com/.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk
10 matches
Mail list logo