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 1053103
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T17:12:03+00:00 2026-05-16T17:12:03+00:00

I am following a railscasts guide ( http://asciicasts.com/episodes/154-polymorphic-association ) for making comments for different

  • 0

I am following a railscasts guide ( http://asciicasts.com/episodes/154-polymorphic-association ) for making comments for different models, but I have run into a problem.

When I try to go to localhost:3000/articles/id/comments/new, I get the following error:

undefined method `comments_path' for #<#<Class:0xb608b40>:0xb607a60>

It is coming from my comment form:

1: <%= form_for([@commentable, @comment]) do |f| %>
2:   <%#= render 'shared/error_messages', :object => f.object %>
3:   <div class="field">
4:     <%= f.label :title %><br />

Here are the contents of the new method of the comments controller:

  def new
    @comment = Comment.new
  end

One thing that differs from the cast, my routes.db has this:

  resources :articles do
    resources :comments
  end

instead of this:

  resources :articles, :has_many => :comments

I get a routes error if I do not do it like this.

Any idea why? I know the guide is a little old, and I am on Rails 3.

  • 1 1 Answer
  • 3 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-05-16T17:12:04+00:00Added an answer on May 16, 2026 at 5:12 pm

    You haven’t assigned the @commentable variable in this your “new” action

    it should be something like

      def new
        # This may need to change as per the class of the commentable field
        @commentable = Article.find(params[:article_id']
        @comment = Comment.new
      end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am following the tutorial http://railscasts.com/episodes/253-carrierwave-file-uploads?view=comments by ryan but he state that we must
I am following Ryan Bate's tutorial: http://railscasts.com/episodes/163-self-referential-association But my setup is slightly different. I
I'm following this tutorial: http://railscasts.com/episodes/253-carrierwave-file-uploads or atleast I want to but would like to
I'm following the railscast for Kaminari (http://railscasts.com/episodes/254-pagination-with-kaminari). But I'm stuck with the controller part.
I'm following http://railscasts.com/episodes/102-auto-complete-association Everything seems fine. I'm trying to create an invoice and also
I'm following Railscast 88 to create a dynamic dependent dropdown menu. http://railscasts.com/episodes/88-dynamic-select-menus I'm rendering
Im following the casts http://railscasts.com/episodes/314-pretty-urls-with-friendlyid?autoplay=true on friendly_id Having a user model with field login
I'm following a Rails cast to implement subscription billing. It's here: http://railscasts.com/episodes/288-billing-with-stripe My code
so I've watched http://railscasts.com/episodes/43-ajax-with-rjs but I have a question: In my view I have
im following the railscasts using jquery tokeninput http://railscasts.com/episodes/258-token-fields-revised in creating autocomplete tag tokens and

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.