NoMethodError in Articles#edit in Ruby on Rails tutorial section 5.11 -


इस तरह से बाहर निकलें: Ubuntu 12.04 64 बिट, रुबी 2.0.0, रेल 4.1.0 < P> मैं आधिकारिक रुबी ऑन रेल ट्यूटोरियल () का पालन करने की कोशिश कर रहा हूं, लेकिन मैं धारा 5.11 में फंस रहा हूं। मैंने लोगों को 5.12 से परेशान किया है, लेकिन 5.11 नहीं, इसलिए मुझे लगा कि मुझे पूछना चाहिए।

यह वह हिस्सा है जहां वे आपको एक फ़ाइल को संपादित करने का तरीका बताते हैं। अब, जैसा कि उन्होंने कहा है, मेरे edit.html। एआरबी फ़ाइल के लिए:

  & lt; h1 & gt; संपादन आलेख & lt; / h1 & gt; & Lt;% = form_for: आलेख, url: articles_path (@article), विधि:: पैच करना | f | & Gt%; & Lt;% if @ article.errors.any? & Gt%; & Lt; div id = "error_explanation" & gt; & lt; h2 & gt; & lt;% = बहुवचन (@ article.errors.count, "त्रुटि")% & gt; इस लेख को सहेजने से प्रतिबंधित किया गया: & lt; / h2 & gt; & LT; ul & gt; & lt;% @ article.errors.full_messages.each do | msg | | & Gt%; & Lt; li & gt; & lt;% = msg% & gt; & lt; / li & gt; & Lt;% end% & gt; & Lt; / ul & gt; & Lt; / div & gt; & Lt;% end% & gt; & Lt; p & gt; & lt;% = f.label: शीर्षक% & gt; & lt; br & gt; & lt;% = f.text_field: शीर्षक% & gt; & Lt; / p & gt; & Lt; p & gt; & lt;% = f.label: टेक्स्ट% & gt; & lt; br & gt; & Lt;% = f.text_area: टेक्स्ट% & gt; & Lt; / p & gt; & Lt; p & gt; & Lt;% = f.submit% & gt; & Lt; / p & gt; & Lt;% end% & gt; & lt;% = link_to 'पीछे', लेख_पथ% & gt;   

जब मैं किसी फ़ाइल को संपादित करने की कोशिश करता हूं, तो मुझे निम्न त्रुटि मिलती है:

  ऑप्शन में ऑप्शन # संपादित करें दिखा रहा है / home / aespielberg / ror / ब्लॉग / ऐप / दृश्य / लेख / संपादित करें.html। एआरबी जहां पंक्ति # 4 उठाया गया: शून्य के लिए अपरिभाषित विधि `त्रुटियां ': NilClass निकाले गए स्रोत (लगभग # 4 लाइन): & lt; h1 & gt; संपादन आलेख & lt; / h1 & gt; & lt;% = form_for: आलेख, url: articles_path (@article), विधि:: पैच करना | f | & Gt%; & Lt;% if @ article.errors.any? & Gt%; & Lt; div id = "error_explanation" & gt; & lt; h2 & gt; & lt;% = बहुवचन (@ article.errors.count, "त्रुटि")% & gt; इस लेख को सहेजने से प्रतिबंधित किया गया: & lt; / h2 & gt; Rails.root: / home / aespielberg / ror / ब्लॉग आवेदन ट्रेस | फ्रेमवर्क ट्रेस | पूर्ण ट्रैस ऐप / दृश्य / लेख / edit.html.erb: 4: `_app_views_articles_edit_html_erb__4315770151411025849_69984046087300 'एप / दृश्य / लेख / संपादित करें.html। एआरबी: 3: में` _app_views_articles_edit_html_erb__4315770151411025849_69984046087300'   <पी में ब्लॉक में > अब, मुझे यकीन नहीं है कि यह क्यों है, क्योंकि अनुच्छेद विरासत में आता है:  
  वर्ग आलेख & lt; ActiveRecord :: बेस पुष्टि करता है: शीर्षक, उपस्थिति: सही, लंबाई: {न्यूनतम: 5} अंत   

जो, ​​जहां तक ​​मैं समझता हूं, वहां है।

और मेरे नियंत्रक:

  वर्ग आलेख कंट्रोलर & lt; ApplicationController def new @article = Article.new end def = लेख = Article.new (article_params) यदि @ article.save redirect_to @article अन्य 'नया' अंत अंत डीईएफ़ शो @article = Article.find (params [: id] ) अंत डीईएफ़ इंडेक्स @ एर्टिक्स = आर्टिकल.ऑल अंत निजी डीईफ़ लेख_परम पैराम्स.रेक्वायर (: आलेख) .पीरमिट (: शीर्षक,: पाठ) अंत डीईएफ़ अद्यतन @ एर्टिकल = आर्टिकलफिड (पैराम्स [: आईडी]) अगर @र्टिकल   

यह मुझे दो प्रश्नों की ओर ले जाता है:

/ p>

  1. यह त्रुटि क्यों हो रही है?
  2. इसे ठीक करने का सही तरीका क्या है?

    आपको संपादित करें और update ऊपर निजी तरीकों को डालना होगा। निजी के नीचे कुछ भी एक निजी तरीका होगा और संपादित करें और अपडेट सार्वजनिक विधियां होनी चाहिए।

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -