0

Say I did rails g scaffold Review artist:string song:string genre:string and created a review object with those fields...would it later be possible to easily add another field like rating:int via a rails command, or would I need to manually edit all the files to include another data field for the form? I know it's possible to just delete the first scaffold and rebuild with the extra field, but I was just wondering if there was an easier way.

Thanks

parameter
  • 894
  • 2
  • 18
  • 35

1 Answers1

0

The scaffold just generates minimalist model, view and controller code along with (usually) a database migration.

If you haven't made any serious changes to any of that code, it may be easier to rerun the scaffold generator. If you haven't run the database migrations, or you haven't committed them, you can add your attributes in the existing migration code and follow up with corresponding changes in the view.

If you've committed the code and someone is already depending on the existing model, you'll want to generate a database change migration to preserve a graceful upgrade/downgrade path.

The scaffold isn't magic, it's just a quick and dirty way of generating code that you can edit.

JasonTrue
  • 19,244
  • 4
  • 34
  • 61
  • thank you for the advice, just wanted to make sure that there wasn't a scaffold command to add some more fields to an already existing one. – parameter Mar 14 '14 at 21:55