그냥 내 모델에서 간단한 validates_presence_of를 작성했는데, 오류가 렌더링 할 때,이 호출새로운 Rails 3 앱의 템플릿이 누락 되었습니까?
Template is missing
Missing template posts/create with {:locale=>[:en, :en], :handlers=>[:builder, :rjs, :erb, :rhtml, :rxml, :haml], :formats=>[:html]} in view paths "/Users/johnsmith/Sites/shwagr/app/views"
오류들이 Rails3에 별도의 전망을 할 필요는 없습니다? 나는 그것이 레일즈 마술이라고 생각했다.
누군가이 문제가 있거나 그것을 올바르게 검증하는 방법을 알고 있다면 궁금하다.
내 모델 :
validates_presence_of :category, :name, :url
내 컨트롤러 :
흥미, 내가 '응용 프로그램/조회/게시물/create.html.haml 터치'
def new
@post = Post.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @post }
end
end
def create
@post = Post.new(params[:post])
if @post.valid? && current_user.posts << @post
respond_to do |format|
if @post.save
format.html { redirect_to(@post, :notice => 'Post was successfully created.') }
format.xml { render :xml => @post, :status => :created, :location => @post }
else
format.html { render :action => "new" }
format.xml { render :xml => @post.errors, :status => :unprocessable_entity }
end
end
end
end
업데이트하고, 이제는 오류를 제거하고 대신 해당 페이지를로드합니다. 근데 왜? 또는 더 중요한 것은 어떻게해야 할 것처럼 new_post_path (@post)로 다시 리디렉션 할 수 있습니까?
No..form은 _form/edit/index/new/show입니다.이 형식은 다음과 같습니다. = form_for @post do | f | -if @ post.errors.any? #errorExplanation % h2 = "# {plural {@ post.errors.count,"error "}}이 게시물의 저장을 금지했습니다." % ul - @ post.errors.full_messages.each do | msg % li = msg 다른 것이 필요합니까? – Trip
이상한 뭔가가 있지만 여기에 메타 링크가 생깁니다. 왜냐하면 유효성 검사는 레일스에서 즉시 작동하기 때문입니다. 내 모델이 위와 같이 보이는지 업데이트했습니다. – Trip
확인. 질문을 편집하여 컨트롤러 코드를 알려주십시오. –