Ruby – Rails Model: Validates_Unique Ness_OF Will not delete the endless space before a unique check? Isn’t the front guide?

Suppose I implement validates_uniqueness_of on the username. If the name’maddy’ already exists, then it will accept the value’maddy’ as the unique value instead of’maddy’. It should remove both sides The spaces. How can this behave?
class Person
before_validation :strip_blanks

protected

def strip_blanks
self.name = self.name.strip
end
end

The source of this snippet contains some discussion about why this is not The default Rails behavior. http://www.ruby-forum.com/topic/166426

Suppose I implement validates_uniqueness_of on the username. If the name’maddy’ is already Exists, then it will accept the value’maddy’ as the only value instead of’maddy’. It should remove the spaces on both sides. How can there be this behavior?

class Person
before_validation :strip_blanks

protected

def strip_blanks
self .name = self.name.strip
end
end

The source of this snippet contains some discussion as to why this is not the default Rails behavior. http://www.ruby -forum.com/topic/166426

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 395 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.