Railsã®ActiveRecordã® validates :uniqueness ãä¿¡ãããã¨æã«ä¸å ·åãæãã¾ãã Railsã®ActiveRecordã§ã¯ã validates :uniqueness => true ã使ç¨ãããã¨ã§ãæå®ããå±æ§ãuniqueã§ãããã¨ãæ¤è¨¼ã§ãã¾ãã ä¾ãã°ãnameã¨emailã¨ããå±æ§ãæã¤Userã¨ããã¯ã©ã¹ã«ã¤ãã¦èãã¾ãã ãã®å ´åã«nameãuniqueã§ããï¼ä¾ãã°yamadaã¨ããnameãè¤æ°åå¨ãããã¨ã許å¯ããªãï¼ãã¨ãæ¤è¨¼ããã«ã¯ãUserã¯ã©ã¹ã®ä¸ã§ä»¥ä¸ã®ããã«validationãè¨è¿°ãã¾ãã class User < ActiveRecord::Base ... validates :name, :presence => true, :uniqueness => true ... end Railsã®ã¢ããªã±ã¼ã·ã§ã³
{{#tags}}- {{label}}
{{/tags}}