Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Joshua Shroy
9,943 PointsDeleting attribute from previously created scaffold in Rails?
I created a scaffold with 3 attributes. I later decided I didn't need one of them. How would I remove it completely?
1 Answer
Maciej Czuchnowski
36,441 PointsYou should create a migration that removes the column (attribute) from that table (model) and then run rake db:migrate again. Read up more on changing tables with migrations:
http://guides.rubyonrails.org/migrations.html#changing-tables
Let me know if you get stuck and need more assistance.
You need something similar to this:
change_table :products do |t|
t.remove :description
end
This removes the description column from the products table.
Of course, you will also need to edit your views etc. to reflect that change.