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

Ticket #2562 (closed defect: fixed)

Opened 4 years ago

Last modified 4 years ago

[PATCH] Fixes problem in 0.14.1 where scaffold always generates the default controller name

Reported by: self@mattmower.com Assigned to: David
Priority: normal Milestone:
Component: Railties Version: 0.13.1
Severity: blocker Keywords: scaffold generator
Cc:

Description

In 0.14.1 the use of

script/generate scaffold <model_name> <controller_name>

would generate a controller with the default <model_name>Controller instead of <controller_name>Controller.

This is because of a change between 0.13.1 and 0.14.1 scaffold_generator.rb

- @controller_name = args.shift @name.pluralize

+ @controller_name = args.shift ActiveRecord::Base.pluralize_table_names ? @name.pluralize : @name

However ?: has a higher precedence than so that @controller_name ends up getting the wrong value. The patch fixes this by putting the RHS in () where it belongs.

@controller_name = args.shift ( ActiveRecord::Base.pluralize_table_names ? @name.pluralize : @name )

With thanks to chris2 and DireRed for their help in sorting it out.

Attachments

fixes_scaffold_generator_creating_wrong_controller_name_patch.diff (0.8 kB) - added by self@mattmower.com on 10/22/05 14:35:28.

Change History

10/22/05 14:35:28 changed by self@mattmower.com

  • attachment fixes_scaffold_generator_creating_wrong_controller_name_patch.diff added.

10/22/05 16:03:47 changed by bitsweat

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

Changeset [2703]. Thanks Matt.