Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #913 (closed: wontfix)

Opened 3 years ago

Last modified 2 years ago

Scaffold generator does not behave as expected.

Reported by: michael@sin.za.net Assigned to: David
Priority: normal Milestone: 1.0
Component: ActiveRecord Version: 0.11.0
Severity: normal Keywords: scaffold, generator, generate, postgres
Cc:

Description

Software versions

Ruby 1.8.2 (2004-12-25), Rails 0.11.0, Postgresql 8.0.1, postgres-pr 0.3.6 (and/or postgres-0.7.1)

Using table of the form: moo(id serial, name varchar(50))

If I initialise a new rails application and generate a model and controller for the moo table and then add:

model :moo
scaffold :moo

to the controller, and

self.table_name = "moo"

to the model; everything works fine, I can add/delete/view records perfectly.

If I instead use the scaffold generator, i.e.:

script/generate scaffold moo moo

it proceeds without error, and the list/show and destroy actions work fine, but the new and edit actions fail to present an input textbox (for the moo name column). To elaborate, instead of something like:

Editing moo
[name textbox]
[Edit button]

I have:

Editing moo
[Edit button]

I then have to manually open edit.rhtml and add the textfield tag, if I want to add/edit data.

Change History

03/23/05 15:13:18 changed by tobi

Probably because the scaffold generator looks for a table called moos.

Can you turn off pruralisation globally and try again?

03/23/05 15:57:50 changed by michael@sin.za.net

  • priority changed from high to normal.

Ah! That worked.

I set self.table_name in the second example, but I didn't even begin to think that the scaffold generator would be looking at the plural table name.

Could I then suggest that a method of specifying the table to inspect is implemented to the generator?

03/23/05 16:47:00 changed by michael@sin.za.net

Adding set_table_name "moo" in the model file doesn't work (generator ignores it) - is this not because script/generate scaffold is there to generate model/controller files, it's not going to use any changes from the existing model file.

Currently I'm using ActiveRecord::Base.pluralize_table_names = false in environment.rb to disable table name guessing.

04/09/05 16:16:31 changed by nzkoz

  • milestone set to 1.0.

06/21/05 17:07:57 changed by david

  • status changed from new to closed.
  • resolution set to wontfix.

Scaffolding is reserved for the common case of following all the rules. There are a lot of exceptions we should otherwise think about honoring, like other names for ids for example. I think we'll just let it rest as a limitation.

06/20/06 03:13:55 changed by somekool@gmail.com

I would also appreciate this as plurialization does not make sense for japanese names.