how can i insert data into table by the help of migration and that table is generated previously through another migration
ruby-on-rails-3, ruby-on-rails-3.1
Solution
This:
Users.new(:username => "Hello", :role => "Admin")
does not insert data into your table. It merely creates a user object. To insert the data you have to call `save` on the object you create:
Users.new(:username => "Hello", :role => "Admin").save
Or better yet, use `create` instead of `new`:
Users.create(:username => "Hello", :role => "Admin")
Problem
I have a role table with user name and role and company. I want to insert data into that table through a new migration file so how can i do this? I got a code like this but how can i use it and where i am not able to understand. ``` class Foo < ActiveRecord::Migration def self.up Users.new(:username => "Hello", :role => "Admin") end def self.down Users.delete_all(:username => "Hello") end end ```