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]
时间: 2024-11-02 13:09:56