Reputation: 159
I'm doing rail for begineer. I create the model Post with a title as string and body as text area. After that, I forgot to add new element in the form which is sub body
So,I add the sub body in 20150120154140_create_posts.rb and schema.rb as shown below
class CreatePosts < ActiveRecord::Migration
def change
create_table :posts do |t|
t.string :title
#Add code below
t.string :subbody
t.text :body
t.timestamps
end
end
end
This is my schema.rb
ActiveRecord::Schema.define(version: 20150122040119) do
create_table "posts", force: true do |t|
t.string "title"
t.string "subbody"
t.text "body"
t.datetime "created_at"
t.datetime "updated_at"
end
end
After I add it , I write rake db:reset on terminal.
When I checked the db in IRB, Its shown in the table.
After I modified the views for createing new Post and submit it's doesn't save it.
Checked in IRB, its said nil at subbody
Upvotes: 0
Views: 51
Reputation: 1147
rake db:reset
doesn't run the migrations. You'll need to rake db:migrate:down
followed by rake db:migrate
. That should work as long as this is your newest migration. For more info, see this post.
Upvotes: 1