首页 > 代码库 > rails [error_messages_for]

rails [error_messages_for]

class Foo < ActiveRecord::Base  unloadable  validates_presence_of :subject  validates_length_of :subject,:maximum => 255end
  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