Note that there are some explanatory texts on larger screens.

plurals
  1. POundefined method `model_name' for NilClass:Class - Rails application
    primarykey
    data
    text
    <p>So I have seen other articles here on stack about this and a lot of the time people are not doing @post = post.new. I read some where to use the plural...??</p> <p>any ways I am getting this error on my discussion code:</p> <p><strong>Model</strong></p> <pre><code>class Discussion &lt; ActiveRecord::Base has_many :comment belongs_to :author attr_accessible :author_id, :content, :title validate :comment, :presence =&gt; true validate :title, :presence =&gt; true end </code></pre> <p><strong>Discussion Controller</strong></p> <pre><code>class DiscussionsController &lt; ApplicationController def index @discussion = Discussion.new @discussions = Discussion.all end def create @discussion = Discussion.create(params[:discussion]) if @discussion.save redirect_to tasks_path, :flash =&gt; {:success =&gt; 'Created a new discussion'} else redirect_to tasks_path, :flash =&gt; {:error =&gt; 'Failed to create a discussion'} end end end </code></pre> <p><strong>Discussion Form</strong></p> <pre><code>&lt;%= form_for @discussion do |f| %&gt; &lt;p&gt;&lt;%= f.label :title %&gt; &lt;%= f.text_field :title %&gt;&lt;/p&gt; &lt;p&gt;&lt;%= f.label :content %&gt; &lt;%= f.text_area :content %&gt;&lt;/p&gt; &lt;% end %&gt; </code></pre> <p><strong>Discussion Routes</strong></p> <pre><code> resources :discussions do resources :comments end </code></pre> <p>Now as far as I know I am doing this right, because I have a task form set up essentially the same way - but I have looked at my code for hours and have googled and tried other examples and now i see this:</p> <pre><code>undefined method `model_name' for NilClass:Class Extracted source (around line #1): 1: &lt;%= form_for @discussion do |f| %&gt; 2: 3: &lt;p&gt;&lt;%= f.label :title %&gt; 4: &lt;%= f.text_field :title %&gt;&lt;/p&gt; </code></pre> <p>Which should mean that I am missing something from my controller.....is it as asilly as a spelling mistake? >.></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload