Newbie question: scaffold not working

I went through a tutorial at
Radar – O’Reilly to get
started with RoR. I really like the idea of the scaffold construct, but
I can’t seem to get it to work the way it was described in the tutorial.
I’ve got a mysql database that is properly configured, and a table
called ‘quotes’ with a column called ‘quote’, and an auto incrementing
primary key of ‘id’. Below is my controller code and model, and the
error I get. Anyone have any idea why this doesn’t just work? Btw,
I’ve got Ruby 1.8.4 (2006-04-14) [i386-mswin32], and I can’t figure out
what version of Rails (or even RubyGems…I used this last night to
install Rails).

In app/controllers:
class QuoteController < ApplicationController
scaffold :quote
end

In app/models:
class Quote < ActiveRecord::Base
end

Here is the error I got:

ArgumentError in Quote#index

Showing
c:/dev/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/templates/scaffolds/list.rhtml
where line #13 raised:

wrong number of arguments (0 for 1)

Extracted source (around line #13):

10: <% for entry in instance_variable_get(“@#{@scaffold_plural_name}”)
%>
11:
12: <% for column in @scaffold_class.content_columns %>
13: <%= entry.send(column.name) %>
14: <% end %>
15: <%= link_to “Show”, :action => “show#{@scaffold_suffix}”,
:id => entry %>
16: <%= link_to “Edit”, :action => “edit#{@scaffold_suffix}”,
:id => entry %>

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

c:/dev/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/templates/scaffolds/list.rhtml:13:in
quote' c:/dev/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/templates/scaffolds/list.rhtml:13:in _run_rhtml_c__dev_ruby_lib_ruby_gems_1468_gems_actionpack_14612465_lib_action_controller_templates_scaffolds_list’
c:/dev/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/templates/scaffolds/list.rhtml:12:in
_run_rhtml_c__dev_ruby_lib_ruby_gems_1468_gems_actionpack_14612465_lib_action_controller_templates_scaffolds_list' c:/dev/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/templates/scaffolds/list.rhtml:10:in _run_rhtml_c__dev_ruby_lib_ruby_gems_1468_gems_actionpack_14612465_lib_action_controller_templates_scaffolds_list’
c:/dev/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/base.rb:316:in
compile_and_render_template' c:/dev/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/base.rb:292:in render_template’
c:/dev/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/base.rb:251:in
render_file' c:/dev/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/scaffolding.rb:168:in render_scaffold’
c:/dev/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/scaffolding.rb:110:in
list' c:/dev/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/scaffolding.rb:97:in index’
c:/dev/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:941:in
perform_action_without_filters' c:/dev/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/filters.rb:368:in perform_action_without_benchmark’
c:/dev/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/benchmarking.rb:69:in
perform_action_without_rescue' c:/dev/ruby/lib/ruby/1.8/benchmark.rb:293:in measure’
c:/dev/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/benchmarking.rb:69:in
perform_action_without_rescue' c:/dev/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/rescue.rb:82:in perform_action’
c:/dev/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:408:in
process_without_filters' c:/dev/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/filters.rb:377:in process_without_session_management_support’
c:/dev/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/session_management.rb:117:in
process' c:/dev/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/dispatcher.rb:38:in dispatch’
c:/dev/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/webrick_server.rb:115:in
handle_dispatch' c:/dev/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/webrick_server.rb:81:in service’
c:/dev/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in service' c:/dev/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in run’
c:/dev/ruby/lib/ruby/1.8/webrick/server.rb:173:in start_thread' c:/dev/ruby/lib/ruby/1.8/webrick/server.rb:162:in start_thread’
c:/dev/ruby/lib/ruby/1.8/webrick/server.rb:95:in start' c:/dev/ruby/lib/ruby/1.8/webrick/server.rb:92:in start’
c:/dev/ruby/lib/ruby/1.8/webrick/server.rb:23:in start' c:/dev/ruby/lib/ruby/1.8/webrick/server.rb:82:in start’
c:/dev/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/webrick_server.rb:67:in
dispatch' c:/dev/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/commands/servers/webrick.rb:59 c:/dev/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in require’
c:/dev/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in
require' c:/dev/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/commands/server.rb:30 c:/dev/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in require’
c:/dev/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in
`require’
script/server:3

c:/dev/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/templates/scaffolds/list.rhtml:13:in
quote' c:/dev/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/templates/scaffolds/list.rhtml:13:in _run_rhtml_c__dev_ruby_lib_ruby_gems_1468_gems_actionpack_14612465_lib_action_controller_templates_scaffolds_list’
c:/dev/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/templates/scaffolds/list.rhtml:12:in
_run_rhtml_c__dev_ruby_lib_ruby_gems_1468_gems_actionpack_14612465_lib_action_controller_templates_scaffolds_list' c:/dev/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/templates/scaffolds/list.rhtml:10:in _run_rhtml_c__dev_ruby_lib_ruby_gems_1468_gems_actionpack_14612465_lib_action_controller_templates_scaffolds_list’
c:/dev/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/base.rb:316:in
compile_and_render_template' c:/dev/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/base.rb:292:in render_template’
c:/dev/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/base.rb:251:in
render_file' c:/dev/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/scaffolding.rb:168:in render_scaffold’
c:/dev/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/scaffolding.rb:110:in
list' c:/dev/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/scaffolding.rb:97:in index’
c:/dev/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:941:in
perform_action_without_filters' c:/dev/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/filters.rb:368:in perform_action_without_benchmark’
c:/dev/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/benchmarking.rb:69:in
perform_action_without_rescue' c:/dev/ruby/lib/ruby/1.8/benchmark.rb:293:in measure’
c:/dev/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/benchmarking.rb:69:in
perform_action_without_rescue' c:/dev/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/rescue.rb:82:in perform_action’
c:/dev/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:408:in
process_without_filters' c:/dev/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/filters.rb:377:in process_without_session_management_support’
c:/dev/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/session_management.rb:117:in
process' c:/dev/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/dispatcher.rb:38:in dispatch’
c:/dev/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/webrick_server.rb:115:in
handle_dispatch' c:/dev/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/webrick_server.rb:81:in service’
c:/dev/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in service' c:/dev/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in run’
c:/dev/ruby/lib/ruby/1.8/webrick/server.rb:173:in start_thread' c:/dev/ruby/lib/ruby/1.8/webrick/server.rb:162:in start_thread’
c:/dev/ruby/lib/ruby/1.8/webrick/server.rb:95:in start' c:/dev/ruby/lib/ruby/1.8/webrick/server.rb:92:in start’
c:/dev/ruby/lib/ruby/1.8/webrick/server.rb:23:in start' c:/dev/ruby/lib/ruby/1.8/webrick/server.rb:82:in start’
c:/dev/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/webrick_server.rb:67:in
dispatch' c:/dev/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/commands/servers/webrick.rb:59 c:/dev/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in require’
c:/dev/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in
require' c:/dev/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/commands/server.rb:30 c:/dev/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in require’
c:/dev/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in
`require’
script/server:3

Request

Parameters: None

Show session dump


flash: !map:ActionController::Flash::FlashHash {}

Response
Headers: {“cookie”=>[], “Cache-Control”=>“no-cache”}

wrong number of arguments (0 for 1)
10: <% for entry in instance_variable_get("@#{@scaffold_plural_name}")
.
.
.
12: <% for column in @scaffold_class.content_columns %>


13:

<%= entry.send(column.name) %>

The error message is stating that you put in a wrong number of arguments
(you aren’t passing any variables at all, where you should be passing
one) in a certain function you were calling - - on line 13 - -
something.SEND(1 varaiable here).

meaning, column.name doesn’t populate anything at all.
one reason i could come up with is that the statment in line 12 (for
column in …) doesn’t populate anything either (hence, the variable
column is incorrect/nil) and that’s why you are getting your error.

i would check to see why @scaffold_class.content_columns isn’t
working…how did the process of scaffolding go? did you do it before
creating the columns in the table? afterwords?

anyhow, good luck, and welcome to ror.

harp

So I tried a few different things, and it turns out that the scaffold
capability was choking because of the fact that I had a column name that
was the singular form of the table. So the table was ‘quotes’ and it
had a column named ‘quote’. When I changed the ‘quote’ column to be
called ‘text’ instead, the scaffold worked just fine.

This seems like a bug to me…where would I report it?

harper wrote:

wrong number of arguments (0 for 1)
10: <% for entry in instance_variable_get("@#{@scaffold_plural_name}")
.
.
.
12: <% for column in @scaffold_class.content_columns %>


13:

<%= entry.send(column.name) %>

The error message is stating that you put in a wrong number of arguments
(you aren’t passing any variables at all, where you should be passing
one) in a certain function you were calling - - on line 13 - -
something.SEND(1 varaiable here).

meaning, column.name doesn’t populate anything at all.
one reason i could come up with is that the statment in line 12 (for
column in …) doesn’t populate anything either (hence, the variable
column is incorrect/nil) and that’s why you are getting your error.

i would check to see why @scaffold_class.content_columns isn’t
working…how did the process of scaffolding go? did you do it before
creating the columns in the table? afterwords?

anyhow, good luck, and welcome to ror.

harp

Brian R. Robinson wrote:

So I tried a few different things, and it turns out that the scaffold
capability was choking because of the fact that I had a column name that
was the singular form of the table. So the table was ‘quotes’ and it
had a column named ‘quote’. When I changed the ‘quote’ column to be
called ‘text’ instead, the scaffold worked just fine.

You’re sure it was the column name that was causing the problems? I just
whipped the same type of app; a controller that scaffolded on :comment,
where I had a ‘comments’ table with a column called ‘comment’, and a
model called ‘Comment’, and everything worked fine.

db/schema.rb:
create_table :comments do |t|
t.column :name, :string
t.column :comment, :text
t.column :user_id, :integer
end

controllers/comment_controller.rb
class CommentController < ApplicationController
scaffold :comment
end

models/comment.rb
class Comment < ActiveRecord::Base
end

Brian R. Robinson wrote:

I can’t figure out
what version of Rails (or even RubyGems…I used this last night to
install Rails).

type 'rails --version" or “gem --version” at the console/command prompt
to see what the version is of the respected apps.

I get the same error. I did the tutorial
http://instantrails.rubyforge.org/tutorial/index.html created a database
called cookbook2, table recipes with column “method” and it didnt’ like
that.

version 1.1.2

James Schementi wrote:

Brian R. Robinson wrote:

I can’t figure out
what version of Rails (or even RubyGems…I used this last night to
install Rails).

type 'rails --version" or “gem --version” at the console/command prompt
to see what the version is of the respected apps.

On Aug 19, 2006, at 4:16 AM, Duana Stanley wrote:

I get the same error. I did the tutorial
http://instantrails.rubyforge.org/tutorial/index.html created a
database
called cookbook2, table recipes with column “method” and it didnt’
like
that.

version 1.1.2

I think that is because method is already defined as a Method…

Merlin:~/rails cbeck$ irb
irb(main):001:0> d = 1
=> 1
irb(main):002:0> d.methods
=> [“to_a”, “%”, “<<”, “respond_to?”, “>>”, “divmod”, “&”, “type”,
“integer?”, “chr”, “protected_methods”, “eql?”, “to_sym”, “*”,
“instance_variable_set”, “+”, “is_a?”, “truncate”, “hash”, “send”,
“to_s”, “-”, “between?”, “modulo”, “singleton_method_added”, “prec”,
“zero?”, “/”, “size”, “class”, “tainted?”, “private_methods”,
send”, “next”, “|”, “untaint”, “id”, “~”, “step”, “to_i”,
“inspect”, “instance_eval”, “prec_i”, “remainder”, “clone”,
“nonzero?”, “public_methods”, “^”, “+@”, “floor”, “extend”, “freeze”,
“-@”, “**”, “quo”, “display”, “id”, “<=>”, “downto”, “to_f”, “<”,
“method”, “methods”, “==”, “===”, “prec_f”, “abs”, “>”, “to_int”,
“nil?”, “dup”, “instance_variables”, “coerce”, “>=”, “instance_of?”,
“ceil”, “<=”, “upto”, “div”, “times”, “object_id”, “=~”,
“singleton_methods”, “equal?”, “succ”, “taint”, “id2name”, “[]”,
“frozen?”, “instance_variable_get”, “kind_of?”, “round”]
irb(main):003:0> d.method
ArgumentError: wrong number of arguments (0 for 1)
from (irb):3:in `method’
from (irb):3
irb(main):004:0>

I’m not sure of the intricacies of rails but this would be my guess.


Craig B.

http://www.luckybonza.com
AIM: kreiggers