2012-11-01ãã1ã¶æéã®è¨äºä¸è¦§
articleãã¼ãã«ãä½æãããï¼ä¸èº«ã¯å¾ã§èããã°ãããï¼ kenmituo@hoge ~/My Documents/Aptana Studio 3 Workspace/hoge $ rails generate model article invoke active_record create db/migrate/20121116071134_create_articles.rb create app/models/aâ¦
æ¨æºã ã¨ã¨ã©ã¼ã¡ãã»ã¼ã¸ã¯æå®ããå ´æã«ããå ¥ãè¾¼ãã§ãããªãã hoge) -%> å ¥åå¤ãå¤ããªãã¨ãã©ãã«åé¡ããããã ï¼ãã£ã¦ãªããèªåããããªã£ãã åè ruby/rails/RailsGuidesããã£ããå訳ãã¦ã¿ãã/Active Record Validations and Callbacksâ¦
ãªããåºãªãã®ã§è¿·èµ°ä¸ controllers/hoge_controller.rb def create @hage = Hoge.new(params[:hoge]) if @hage.save flash[:notice]="æ°è¦ç»é²ããã¾ãã" redirect_to :action=>:show, :id=>@hage else flash[:notice]="ã ã" p "errors", @hage.errors râ¦
ã¢ãã«ã«ä»è¾¼ãã¡ã¼ã«ã¢ãã¬ã¹ã¨é»è©±çªå·ã®æ¤è¨¼ validates :email, :format=>{:with=>/^[a-z0-9_.-]+@([a-z0-9-]+\.)+[a-z]{2,4}$/i, :message=>":ãã¶ãæ£ãããªã", :allow_blank=>true} validates :phone, :format=>{:with=>/^[0-9-]/, :message=>"ï¼åè§â¦