This project is archived and is in readonly mode.

#3978 ✓invalid
Sam Goldstein

In generators #gsub_file should not silently alter files.

Reported by Sam Goldstein | February 17th, 2010 @ 04:04 PM

This issue was originally filed in cucumber-rails, but it appears the root issue is actually in Rails' built in generators. The use of #gsub_file in generator code will overwrite/alter files without providing any indication to the user that it has done so. Possibly it should call #force_file_collision.

Here is a link to the original cucumber-rails ticket discussing this, and some excerpts from it:

http://github.com/aslakhellesoy/cucumber-rails/issues/issue/15

=============

samg: Running script/generate cucumber rewrites my database.yml file, yet gives no indication that it has done this.

... which was difficult to track down since I had no indication that the generate script would touch database.yml. The resulting error was difficult to trace since database.yml is frequently ignored in SCM; you can't rely on git to tell you it has been altered.

... The generate script should ask before it touches database.yml ...

=============

aslakhellesoy: The generator is using Rails' generator API, more specifically #gsub_file. This method doesn't ask the user about overwrite [Ynaqdh] (the #force_file_collision? method) although I agree it should. The right place to address this is in Rails itself. Please send them a patch or create an issue for it (if it doesn't exist already).

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Pages