rails ã§æ®éã« scaffold ãã㨠id ã URL ã«å ¥ã£ã¦ example.com/users/:id ã¨ãªãã ããã twitter.com/myname ã¨ã github.com/yourname ã¿ããã«ãããæãããã å®ç¾ã«ã¯ 2 éãã®æ¹æ³ãããã¨æãããã to_param ã使ãæ¹æ³ activerecord ã« to_param ã¨ããã¡ã½ããããã£ã¦ãããã使ã㨠URL ã® :id ã®é¨åã« id 以å¤ãæå®ã§ããããã«ãªãã user.rb class User < ActiveRecord::Base validates_presence_of :username validates_uniqueness_of :username, case_sensitive: false def to_param username end end
{{#tags}}- {{label}}
{{/tags}}