If you have not clicked on the transfer yet, you can edit db / migrate / 201112 * create_items.rb and add the following line:
add_column :items, :users_id, :integer
If you have already moved the migration, create another:
rails generate migration AddUsersIdToItems users_id:integer rake db:migrate
Then you have to manually edit the scaffold code:
vi app/views/items/_form.html.erb
Copy the <div> for subcategory_id and change it to: users_id
<div class="field"> <%= f.label :subcategory_id %><br /> <%= f.number_field :subcategory_id %> </div> <div class="field"> <%= f.label :users_id %><br /> <%= f.number_field :users_id %> </div>
Alternatively, if you use git, you can run "git checkout". after starting the first scaffold generator, which cancels all your changes, you can start it again.
source share