Forum: Ruby N00b request help with scaffold- undefined method 'body=' er

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
E091bba2ec34513f01b75235bc2ced9c?d=identicon&s=25 na (Guest)
on 2006-02-26 03:36
(Received via mailing list)
Hey guys,

I'm trying to work my way through the Ruby on Rails tutorial building
CRUD actions using scaffold based on a single database table.

the "list" action seems to work well, but all other actions result in
errors.

See trace below ..

I am only 2 hours into my Ruby (rails) experience and I have no idea how
to track down this bug.

Here's the top part of my ResponseController code:

class ResponsesController < ApplicationController
   def index
     list
     render :action => 'list'
   end

   def list
     @response_pages, @responses = paginate :responses, :per_page => 10
   end

   def show
     @response = Response.find(params[:id])
   end

   def new
     @response = Response.new
   end


Any help appreciated!

Thanks!




undefined method `body=' for #<Response:0xb756fed8>

RAILS_ROOT: script/../config/..
Application Trace | Framework Trace | Full Trace

/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:1498:in
`method_missing'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/base.rb:694:in
`erase_render_results'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/base.rb:712:in
`erase_results'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/rescue.rb:28:in
`rescue_action'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/rescue.rb:108:in
`perform_action'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/base.rb:369:in
`process_without_session_management_support'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/session_management.rb:116:in
`process'
/usr/local/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/dispatcher.rb:38:in
`dispatch'
/usr/local/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/webrick_server.rb:117:in
`handle_dispatch'
/usr/local/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/webrick_server.rb:83:in
`service'
/usr/local/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/usr/local/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/usr/local/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/usr/local/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/usr/local/lib/ruby/1.8/webrick/server.rb:95:in `start'
/usr/local/lib/ruby/1.8/webrick/server.rb:92:in `start'
/usr/local/lib/ruby/1.8/webrick/server.rb:23:in `start'
/usr/local/lib/ruby/1.8/webrick/server.rb:82:in `start'
/usr/local/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/webrick_server.rb:69:in
`dispatch'
/usr/local/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/commands/servers/webrick.rb:59
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in
`require'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:214:in
`require'
/usr/local/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/commands/server.rb:28
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in
`require'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:214:in
`require'
A77873df3a9766b208e009248a2a9a56?d=identicon&s=25 Hampton (Guest)
on 2006-02-26 16:59
(Received via mailing list)
If I had this error, I'd guess that I don't have the attribute "body"
in my "responses" table. Though, I don't know the particulars of your
setup, so it could be many things.

However, please note that scaffolding is not the preferred way to learn
Rails. And, secondly, there is a rails dedicated group that is probably
a better place for rails questions.

But, anyhow, goodluck with it!

-hampton.
87c8c00547d60456371a0cf4c342ad0e?d=identicon&s=25 Guillaume Benny (Guest)
on 2006-02-26 17:24
(Received via mailing list)
>
>    end
>
>

Hi,

 My guess is that "response" is something special in Rails (so is
"request"
if I remember correctly). You are probably overwriting a Rails instance
variable... Try renaming @response to something else. It might even be
your
"Response" model that's confusing Rails: maybe there is a Response class
in
Rails. Try renaming it to something else...

 I hope this will help...

 Guillaume
A659b00d621e0546df20527e0f5fb8bd?d=identicon&s=25 Jeff McNeil (Guest)
on 2006-02-26 17:42
(Received via mailing list)
Shouldn't you also be inheriting from ActionController and not
ApplicationController?  Have a look at the ActionController class
(http://rubyonrails.org/api/classes/ActionControlle...).
I've always thought that ApplicationController was a top-level abstract?

Thanks,

Jeff
(Oh, hi! I don't post much, but I enjoy reading what everyone else
does =)
E091bba2ec34513f01b75235bc2ced9c?d=identicon&s=25 na (Guest)
on 2006-02-26 18:44
(Received via mailing list)
Thanks, Guillaume.

This was the problem.  I renamed my controller and things started
working as they were designed.

Thankyou,
na
This topic is locked and can not be replied to.