I have a Mysql database with a large amount of data and tables. But i need to know how to use this Mysql data in the my new rails application. I’ve been learning Rails from a little time now. i know the basics of creating a scaffold which in turn creates models and controllers, but i’m unclear how to import a DB and use it.
Can anyone explain or provide me with a link on how to get over this.
This is my migration after running a simple scaffold and i ran rake db:migrate after adding an email string there and nothing happened..:
class CreateProducts < ActiveRecord::Migration
def change
create_table :products do |t|
t.string :title
t.text :description
t.string :image_url
t.decimal :price, :precision => 8, :scale => 2
>> t.string :email
t.timestamps
end
end
end
If you need to import that data from your current database into the one for your app, I recommend using Sequel Pro. It’s a great GUI for MySQL. You can use it to export the database you want, say as a .csv file, and import it into your new database.
Regarding your migration, running a scaffold and running
rake db:migratewill just set your database up; it won’t add any data. So here, you’ve set it to create yourproductstable, and specified the data types for its attributes.But in order to get data in there, you can only do that via a form with your application, or by importing data.