码迷,mamicode.com
首页 > 其他好文 > 详细

rails [error_messages_for]

时间:2014-07-07 18:21:22      阅读:240      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   cti   html   for   

class Foo < ActiveRecord::Base
  unloadable
  validates_presence_of :subject
  validates_length_of :subject,:maximum => 255
end
  def create
    @foo =Foo.new(params[:foo])
    @foo.project_id =@project.id
    if @foo.save
      flash[:notice] = l(:notice_successful_create)
      if params[:continue]
        redirect_to :action=>new
      else
        redirect_to :action=>show,:id=>@foo.id
      end
    else
      respond_to do |format|
        format.html { render :action => new }
        format.api  { render_validation_errors(@foo) }
      end
    end
  end

 

rails [error_messages_for],布布扣,bubuko.com

rails [error_messages_for]

标签:style   blog   color   cti   html   for   

原文地址:http://www.cnblogs.com/yuzhengdong/p/3813500.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!