Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8477341
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:26:23+00:00 2026-06-10T18:26:23+00:00

So I have seen other articles here on stack about this and a lot

  • 0

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…??

any ways I am getting this error on my discussion code:

Model

class Discussion < ActiveRecord::Base
  has_many :comment
  belongs_to :author
  attr_accessible :author_id, :content, :title

  validate :comment, :presence => true
  validate :title, :presence => true
end

Discussion Controller

class DiscussionsController < 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 => {:success => 'Created a new discussion'}
    else
      redirect_to tasks_path, :flash => {:error => 'Failed to create a discussion'}
    end
  end
end

Discussion Form

<%= form_for @discussion do |f| %>

    <p><%= f.label :title %>
    <%= f.text_field :title %></p>

    <p><%= f.label :content %>
    <%= f.text_area :content %></p>

<% end %>

Discussion Routes

  resources :discussions do
    resources :comments
  end

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:

undefined method `model_name' for NilClass:Class

Extracted source (around line #1):

1: <%= form_for @discussion do |f| %>
2: 
3:  <p><%= f.label :title %>
4:  <%= f.text_field :title %></p>

Which should mean that I am missing something from my controller…..is it as asilly as a spelling mistake? >.>

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T18:26:25+00:00Added an answer on June 10, 2026 at 6:26 pm

    I believe your problem is that you are trying to create a discussion on a task form but have only defined the discussion controller and not the task controller.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have seen other questions on here related to this, but I have their
I have seen other people who have had this question, but most of the
I have seen a couple of articles about ViewWillAppear and ViewDidAppear not firing under
i have seen other blogs and SO questions relating to this issue but none
I googled,I binged,I already have seen the other duplicates here,but none of them work
I have seen some of the other answers on this topic but dont really
I have seen in some source code (by other developers) something like this: #import
I have seen other people questions but found none that applied to what I'm
I want to use the text input field seen here: http://simple-form-bootstrap.plataformatec.com.br/articles/new (It's the second
I have seen the other answers but I can't get this to work. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.