Hi everyone,
I am attempting to connect an already existing mysql database with Rails. For This I can't use the traditional "generate scaffold" and "rake db:migrate" because (I think), I'll loose the data already existing in that database table. So what I did was, I generated a scaffold for my table, and instead of running db:migrate, I added a set_table_name to my model.
Of course, I get a bunch of errors whenever I do things like Product.all, because I think my model's properties are not properly mapped to the database table columns. So I began poking around my rails app rolder and found a file named schema.rb in the "db" folder inside my app, with content like this:
create_table "users", :force => true do |t| t.text "username" t.text "password" t.text "email" t.text "real_name" t.datetime "created_at" t.datetime "updated_at" end
There were also some comments about not editing this file manually, but to use migrations instead.
So the questions are: How does Rails know which properties from the model to match to the database fields? What is the purpose of db\schema.rb? And how, then, would you reccomend that I connect this table to my Rails app?