laredotornado-8iDLEspWrrZBDgjK7y7TUQ@public.gmane.org
2008-Mar-19 14:56 UTC
allow_blank in older version of Rails
Hi, Our hosting company is using RoR 1.2.3. This version does not seem to support the "allow_blank => true" validation rule. I have two questions ... 1. Is it possible to combine other validation rules to simulate "allow_blank"? 2. If #1 is not possible, is it possible to write a plugin that would allow me to use the "allow_blank" directive? Thanks, - Dave --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
laredotornado-8iDLEspWrrZBDgjK7y7TUQ@public.gmane.org wrote:> Our hosting company is using RoR 1.2.3. This version does not seem to > support the "allow_blank => true" validation rule. I have two > questions ... > > 1. Is it possible to combine other validation rules to simulate > "allow_blank"?Add option :if => proc { |m| !m.blank? } -- We develop, watch us RoR, in numbers too big to ignore. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
laredotornado-8iDLEspWrrZBDgjK7y7TUQ@public.gmane.org
2008-Mar-19 21:53 UTC
Re: allow_blank in older version of Rails
Thanks, but that didn''t seem to work. When I left my "fax" field blank, I got an error message returned from validation "Fax cannot be blank". Here''s my validation rule: validates_presence_of :fax, :if => proc { |m| !m.blank? } What I would like is for the field to be allowed to be empty or nil, but because of RoR 1.2.3 I can''t use allow_blank. - Dave On Mar 19, 11:11 am, Mark Reginald James <m...-bzGI/hKkdgQnC9Muvcwxkw@public.gmane.org> wrote:> laredotorn...-8iDLEspWrrZBDgjK7y7TUQ@public.gmane.org wrote: > > Our hosting company is using RoR 1.2.3. This version does not seem to > > support the "allow_blank => true" validation rule. I have two > > questions ... > > > 1. Is it possible to combine other validation rules to simulate > > "allow_blank"? > > Add option > :if => proc { |m| !m.blank? } > > -- > We develop, watch us RoR, in numbers too big to ignore.--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 19 Mar 2008, at 21:53, laredotornado-8iDLEspWrrZBDgjK7y7TUQ@public.gmane.org wrote:> > Thanks, but that didn''t seem to work. When I left my "fax" field > blank, I got an error message returned from validation "Fax cannot be > blank". Here''s my validation rule: > > validates_presence_of :fax, :if => proc { |m| !m.blank? } > > What I would like is for the field to be allowed to be empty or nil, > but because of RoR 1.2.3 I can''t use allow_blank. - Dave >The object that gets passed to the proc is the record itself, so you need m.fax.blank? Fred> On Mar 19, 11:11 am, Mark Reginald James <m...-bzGI/hKkdgQnC9Muvcwxkw@public.gmane.org> wrote: >> laredotorn...-8iDLEspWrrZBDgjK7y7TUQ@public.gmane.org wrote: >>> Our hosting company is using RoR 1.2.3. This version does not >>> seem to >>> support the "allow_blank => true" validation rule. I have two >>> questions ... >> >>> 1. Is it possible to combine other validation rules to simulate >>> "allow_blank"? >> >> Add option >> :if => proc { |m| !m.blank? } >> >> -- >> We develop, watch us RoR, in numbers too big to ignore. > --~--~---------~--~----~------------~-------~--~----~ > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en > -~----------~----~----~----~------~----~------~--~--- >
Frederick Cheung wrote:> The object that gets passed to the proc is the record itself, so you > need m.fax.blank?Whoops, thanks Fred. Another 4am blunder. -- We develop, watch us RoR, in numbers too big to ignore. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
laredotornado-8iDLEspWrrZBDgjK7y7TUQ@public.gmane.org
2008-Mar-20 17:14 UTC
Re: allow_blank in older version of Rails
Thanks guys. Let me go one step further. I downloaded a "validates_as_phone" plugin. So what I want to do is only validate the fax field is a user has entered a non-empty value. However, right now, this rule validates_as_phone :fax, :if => proc { |m| m.blank? } doesn''t kick in, even if the user has entered a value like "111". How can I adjust the above? - Dave On Mar 19, 7:07 pm, Mark Reginald James <m...-bzGI/hKkdgQnC9Muvcwxkw@public.gmane.org> wrote:> Frederick Cheung wrote: > > The object that gets passed to the proc is the record itself, so you > > need m.fax.blank? > > Whoops, thanks Fred. Another 4am blunder. > > -- > We develop, watch us RoR, in numbers too big to ignore.--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 20 Mar 2008, at 17:14, laredotornado-8iDLEspWrrZBDgjK7y7TUQ@public.gmane.org wrote:> > Thanks guys. Let me go one step further. I downloaded a > "validates_as_phone" plugin. So what I want to do is only validate > the fax field is a user has entered a non-empty value. However, right > now, this rule > > validates_as_phone :fax, :if => proc { |m| m.blank? } >Like i said before, that needs to be m.fax.blank?> doesn''t kick in, even if the user has entered a value like "111". How > can I adjust the above? > > - Dave > > On Mar 19, 7:07 pm, Mark Reginald James <m...-bzGI/hKkdgQnC9Muvcwxkw@public.gmane.org> wrote: >> Frederick Cheung wrote: >>> The object that gets passed to the proc is the record itself, so you >>> need m.fax.blank? >> >> Whoops, thanks Fred. Another 4am blunder. >> >> -- >> We develop, watch us RoR, in numbers too big to ignore. > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
laredotornado-8iDLEspWrrZBDgjK7y7TUQ@public.gmane.org
2008-Mar-20 19:24 UTC
Re: allow_blank in older version of Rails
My bad, and it''s not even 4 in the morning. Thanks for the follow-up, Fred. Works great, - Dave On Mar 20, 12:25 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 20 Mar 2008, at 17:14, laredotorn...-8iDLEspWrrZBDgjK7y7TUQ@public.gmane.org wrote: > > > > > Thanks guys. Let me go one step further. I downloaded a > > "validates_as_phone" plugin. So what I want to do is only validate > > the fax field is a user has entered a non-empty value. However, right > > now, this rule > > > validates_as_phone :fax, :if => proc { |m| m.blank? } > > Like i said before, that needs to be m.fax.blank? > > > > > doesn''t kick in, even if the user has entered a value like "111". How > > can I adjust the above? > > > - Dave > > > On Mar 19, 7:07 pm, Mark Reginald James <m...-bzGI/hKkdgQnC9Muvcwxkw@public.gmane.org> wrote: > >> Frederick Cheung wrote: > >>> The object that gets passed to the proc is the record itself, so you > >>> need m.fax.blank? > > >> Whoops, thanks Fred. Another 4am blunder. > > >> -- > >> We develop, watch us RoR, in numbers too big to ignore.- Hide quoted text - > > - Show quoted text ---~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung wrote:> On 20 Mar 2008, at 17:14, laredotornado-8iDLEspWrrZBDgjK7y7TUQ@public.gmane.org wrote: >> validates_as_phone :fax, :if => proc { |m| m.blank? } >> > Like i said before, that needs to be m.fax.blank?Or !m.fax.blank? -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Have you tried :allow_nil => true ? I use that on 1.2.x and 2.0.2. Peace, Phillip -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---