बस मेरे मॉडल में एक साधारण validates_presence_of लेखन की कोशिश की, और जब त्रुटियों रेंडर करने के लिए प्रयास करते हैं, यह इस कॉल:नए रेल 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
मेरे नियंत्रक:
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
अद्यतन
दिलचस्प है, मैं 'टच एप्लिकेशन/विचारों/पदों/create.html.haml', और अब यह त्रुटि को हटा दिया और इसके बजाय उस पृष्ठ को लोड करता है। लेकिन यह क्यों होगा? या सबसे महत्वपूर्ण बात यह है कि, मैं इसे वापस नए_पोस्ट_पैथ (@ पोस्ट) पर रीडायरेक्ट कैसे कर सकता हूं जैसे इसे करना चाहिए?
No..I एक _form/संपादित करें/सूचकांक/नई/शो है ..और इस फार्म यह था के साथ आया था .. = form_for @post बनाने करो | एफ | -if @ post.errors.any? #errorExplanation % h2 = "# {pluralize (@ post.errors.count," त्रुटि ")} इस पोस्ट को सहेजे जाने से निषिद्ध:" % उल - @ post.errors.full_messages.each करना | msg | % li = msg इसे किसी और चीज की आवश्यकता है? – Trip
हालांकि कुछ अजीब, मेथिंक यद्यपि हो रहा है। चूंकि सत्यापन 'रेल' में बॉक्स के ठीक बाहर काम करता है। मैंने अपडेट किया कि मेरे मॉडल ऊपर की तरह दिखते हैं। – Trip
ठीक है। कृपया नियंत्रक कोड दिखाने के लिए कृपया अपना प्रश्न संपादित करें। –