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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T20:16:36+00:00 2026-05-14T20:16:36+00:00

I am going over some basic guides in Rails, reviewing the basics and such

  • 0

I am going over some basic guides in Rails, reviewing the basics
and such for an upcoming exam. One of the guides included was the
sort-of-standard getting started guide over at guide.rubyonrails.org.
Here is the link if you need it. Also all my code is for my app is
from there, so I have no problem releasing any of my code since it
should be the same as shown there. I didn’t do a copy paste, but I
basically was typing with Vim in one half of my screen and the web
page in the other half, typing what I see.

http://guides.rubyonrails.org/getting_started.html

So like I said, I am going along the guide when I noticed past a
certain point in the tutorial, I was always getting an error on the
site. To find the section of code, just hit Ctrl+f on the page (or
whatever you have search/find set to) and enter “accepts_”. This
should immediately direct you to this chunk of code.

class Post < ActiveRecord::Base
  validates_presence_of :name, :title
  validates_length_of :title, :minimum => 5
  has_many :comments
  has_many :tags

  accepts_nested_attributes_for :tags, :allow_destroy => :true  ,
   :reject_if => proc { |attrs| attrs.all? { |k, v| v.blank? } }
end

So I tried putting this in my code. It is in
~/Rails/blog/app/models/post.rb in case you are wondering. However,
even after all the other code I put in past that in the guide, hoping
I was just missing some line of code that would come up later in the
guide. But nothing, same error every time. This is what I get.


NoMethodError in PostsController#index

undefined method `accepts_nested_attributes_for’ for #<Class:0xb7109f98>

/usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/base.rb:1833:in
`method_missing’
app/models/post.rb:7
app/controllers/posts_controller.rb:9:in `index’

Request

Parameters:

None

Response

Headers:

{“Content-Type”=>””,
“cookie”=>[],
“Cache-Control”=>”no-cache”}


Now, I copied the above code from the guide. The two code sections I
edited mentioned in the error message I will paste as is below.


class PostsController < ApplicationController
  # GET /posts
  # GET /posts.xml

  before_filter :find_post,
    :only => [:show, :edit, :update, :destroy]

  def index
    @posts = Post.find(:all) # <= the line 9 referred to in error message

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @posts }
    end
  end

class Post < ActiveRecord::Base
  validates_presence_of :name, :title
  validates_length_of :title, :minimum => 5
  has_many :comments
  has_many :tags

  accepts_nested_attributes_for :tags, :allow_destroy => :true  , # <= problem
    :reject_if => proc { |attrs| attrs.all? { |k, v| v.blank? } }
end

Also here is gem local gem list. I do note that they are a bit out of date, but the default Rails install any of the school machines (an environment likely for my exam) is basically ‘gem install rails –version 2.2.2’ and since they are windows machines, they come with all the normal windows ruby gems that comes with the ruby installer. However, I am running this off a Debian virtual machine of mine, but trying to set it up similarly and I figured the windows ruby gems wouldn’t change anything in Rails.

*** LOCAL GEMS ***

actionmailer (2.2.2)
actionpack (2.2.2)
activerecord (2.2.2)
activeresource (2.2.2)
activesupport (2.2.2)
gem_plugin (0.2.3)
hpricot (0.8.2)
linecache (0.43)
log4r (1.1.7)
ptools (1.1.9)
rack (1.1.0)
rails (2.2.2)
rake (0.8.7)
sqlite3-ruby (1.2.3)
  • 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-05-14T20:16:37+00:00Added an answer on May 14, 2026 at 8:16 pm

    If you look on http://apidock.com/rails/ActiveRecord/NestedAttributes/ClassMethods/accepts_nested_attributes_for you’ll see that accepts_nested_attributes_for only exists since Rails 2.3.2, so I’m afraid you won’t have that functionality if you’re running off of 2.2.

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

Sidebar

Related Questions

Hi I'm just going over some basic javascript and I came across this piece
I'm preparing for an exam and after going over some sample exercises (which have
I am going over some OO basics and trying to understand why is there
I was going over some old C code (listed below) with a view to
I've just been learning some jQUery to get a basic image gallery going on
I'm trying my luck at some basic animation following a basic tutorial over here
I'm going over some c# tutorial that states the following: After it finds the
I am going over some code i wrote in 2006 as an undergrad. It's
I'm doing some basic database learning on Oracle 11g over a Citrix client. The
I have been going nuts over this issue for some time and I am

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.