12.16.2013

Rails 4 Connect Existing Database

Once connect strings are specified in database.yml file, just add a model as follows:
class TestResult < ActiveRecord::Base
  self.table_name = "Test"
  self.primary_key = "testId"
end
Now, lets check from the console
$ rails c
Loading development environment (Rails 4.0.2)
2.0.0p353 :002 > TestResult.column_names
 => ["testId", "analysis", "archive", "baseline", "description", "engineer", "name", "project", "reference", "retention", "link", "errors"] 

No comments:

Post a Comment