rails -> add a column -> NoMethodError in Admin#edit

P

Phlip

[While I try to get on the Rails mailing list here...]

Rubies:

I am a Ruby on Rails newbie, and have been reading the book, "Agile Web
Development with Rails", by Thomas & Hansson.

I seem to be stuck on page 61. The shtick is we create a database table,
then go back and add a column. The column appears fine in my SQLite3
database, and I used its test fixture to populate the column.

Then to rebuild the table's admin interface, I invoke "ruby script/generate
scaffold Product Admin"... But the new column does not show up on the
/admin/show/1 page, and /admin/edit/1 complains like this:

----8<---------------------------------

NoMethodError in Admin#edit

Showing app/views/admin/_form.rhtml where line #17 raised:

undefined method `strength' for #<Champ:0xb742ca68>

Extracted source (around line #17):

14: <%= text_field 'champ', 'account' %></p>
15:
16: <p><label for="champ_strength">Strength</label><br/>
17: <%= text_field 'champ', 'strength' %></p>
18: <!--[eoform:champ]-->
19:

Trace of template inclusion: /app/views/admin/edit.rhtml

----8<---------------------------------

Now because I naturally don't understand the entire stack yet, I don't know
how to work-around this, or how to fix it directly. Any help?
 
P

Phlip

Phlip said:
I am a Ruby on Rails newbie, and have been reading the book, "Agile Web
Development with Rails", by Thomas & Hansson.

Oookay - the book told me I rarely need to restart the server. (It's
Webrick, so maybe it carries more state than it should!)

I bounce the server and the problem goes away.

A digression about Rails and this book: When Dave and ... Dave wrote this
book, they knew their target audience would consist mostly of developers
experienced with writing websites using Brand X.

Under Brand X, you must write endless rendundant boilerplate code to get
anything done. So for each website construction step, /Agile...Rails/
typically announces all the stuff that you _don't_ need to do, such as write
database connection systems from scratch, construct SQL statements from huge
strings, squeeze together MVC yourself...

....or bounce the friggin' server. So now I know to bounce it after changing
the schema. The book probably says that somewhere...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,705
Latest member
Stefkari24

Latest Threads

Top