Validates_format_of :email example available on api.rubyonrails.org is throwing errors. class Person < ActiveRecord::Base validates_format_of :email, :with => %r\A([^@\s]+)@((?:[-a-z0-9]+.)+[a-z]{2,})\Z/, :on => :create end validates :email, :format => { :with => %r\A([^@\s]+)@((?:[-a-z0-9]+.)+[a-z]{2,})\Z/, :on => :create } Currently i am using rails 3.2.8 versions. On loading getting the error as "syntax error, unexpected '']'', expecting keyword_end" -- 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 To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/TSJ7yjFoFAcJ. For more options, visit https://groups.google.com/groups/opt_out.
On Wed, Oct 10, 2012 at 8:59 AM, jude <judearasu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> class Person < ActiveRecord::Base validates_format_of :email, :with => > %r\A([^@\s]+)@((?:[-a-z0-9]+.)+[a-z]{2,})\Z/, :on => :create end> validates :email, :format => { :with => > %r\A([^@\s]+)@((?:[-a-z0-9]+.)+[a-z]{2,})\Z/, :on => :create }%r\A([^@\s]+)@((?:[-a-z0-9]+.)+[a-z]{2,})\Z/ %r\A\Z/ %r/ Maybe use %r!! instead of %r/? -- 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 https://groups.google.com/groups/opt_out.