Is it my environment? Is something wrong, cause I thought this should
just work?
I have a simple table and I created a model and a controller:
ruby script/generate controller Restaurant
ruby script/generate model Restaurant
I edited the controller to this:
class RestaurantController < ApplicationController
scaffold :Restaurant
end
I run it and:
http://0.0.0.0:3000/Restaurant works fine, gives me a list of
restaurants.
If I click on edit though I get this:
Showing
usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/templates/scaffolds/edit.rhtml
where line #4 raised:
wrong number of arguments (0 for 1)
Extracted source (around line #4):
1:
Editing <%= @scaffold_singular_name %>
2:
3: <%= error_messages_for(@scaffold_singular_name) %>
4: <%= form(@scaffold_singular_name, :action =>
“update#{@scaffold_suffix}”) %>
5:
6: <%= link_to “Show”, :action => “show#{@scaffold_suffix}”, :id =>
instance_variable_get(“@#{@scaffold_singular_name}”) %> |
7: <%= link_to “Back”, :action => “list#{@scaffold_suffix}” %>
Likewise if I click on New:
ArgumentError in Restaurant#new
Showing
usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/templates/scaffolds/new.rhtml
where line #4 raised:
wrong number of arguments (0 for 1)
Extracted source (around line #4):
1:
New <%= @scaffold_singular_name %>
2:
3: <%= error_messages_for(@scaffold_singular_name) %>
4: <%= form(@scaffold_singular_name, :action =>
“create#{@scaffold_suffix}”) %>
5:
6: <%= link_to “Back”, :action => “list#{@scaffold_suffix}” %>
Here’s my table definition;
CREATE TABLE restaurants
(
id
INTEGER NOT NULL AUTO_INCREMENT,
name
VARCHAR(100) NOT NULL DEFAULT ‘’,
phone
VARCHAR(14) NOT NULL DEFAULT ‘’,
fax
VARCHAR(14) NOT NULL DEFAULT ‘’,
email
VARCHAR(100) DEFAULT ‘’,
web
VARCHAR(100) DEFAULT ‘’,
address1
VARCHAR(100) NOT NULL DEFAULT ‘’,
address2
VARCHAR(100) DEFAULT ‘’,
city
VARCHAR(100) NOT NULL DEFAULT ‘’,
state
CHAR(2) NOT NULL DEFAULT ‘’,
zip
VARCHAR(10) NOT NULL DEFAULT ‘’,
open
BOOLEAN NOT NULL DEFAULT 0,
PRIMARY KEY(id
)
)
ENGINE = InnoDB
CHARACTER SET utf8;
This on Mac OSX. I set up Ruby and Rails accoring to this: