Hello, I am trying to put some validation using active records onto form fields. like this - validates_length_of :tag_list, :maximum => 2 When i provide value of tag_list as "abc" then it gives the proper message that length cannot be more than two. And when i provide value of tag_list as "abc xyz" then my application accepts the data, which should not happen because the complete length of input data is more than 2. So i think when i include space in input data then it counts the words and if space is not there in input than the charcters will be counted. Could anyone help me out here? Thanks in advance!! -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Are you using the acts_as_taggable plugin? ''Cause then tag_list varies between string and array. Don''t know if that''s the case here though. --Lasse 2010/2/15 Web Developer <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>> Hello, > > I am trying to put some validation using active records onto form > fields. > like this - > > validates_length_of :tag_list, :maximum => 2 > > When i provide value of tag_list as "abc" then it gives the proper > message > that length cannot be more than two. And when i provide value of > tag_list as > "abc xyz" then my application accepts the data, which should not happen > because the complete length of input data is more than 2. > So i think when i include space in input data then it counts the words > and > if space is not there in input than the charcters will be counted. > > Could anyone help me out here? Thanks in advance!! > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Yes, i am using acts_as_taggable plugin. But then what could be the solution for this? -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Any solution to this???? I am stuck :-( -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Feb 17, 11:16 am, Web Developer <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Any solution to this???? > I am stuck :-(Well if acts_as_taggable behaves as Lasse says then sounds like you need to write a custom validation method that checks the various cases that can occur. Something like validates :tags_long_enough def tags_long_enough if ... errors.add(:tag_list, "those tags are not nice") end end would probably do the job Fred -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.
What are you trying to validate? That the tag_list doesn''t contain elements longer than 2 charaters? I reckon you''d have to do the validation manually then private def validate #Do some checks on self.tag_list and if it fails: errors.add(:tag_list, ''cannot contain elements longer than 2 characters) end -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.