I'm a bit new to Sinatra / Datamapper and I am currently attempting to create a model based on an existing table.
We have an employee forum which stores the users' employee ID when they create a post. Obviously when we display the information, we want to show the employees' real name (rather than their employee ID), so we have a quick reference table that is truncated and repopulated daily with the following information:
EMPLOYEE_ID (NUMBER)
FORENAME (VARCHAR2 150)
SURNAME (VARCHAR2 150)
I'm attempting to use the following code:
require 'data_mapper'
DataMapper.setup(:default, 'oracle://xxx:xxx@xxx.xxx')
class Emp
include DataMapper::Resource
storage_names[:legacy] = 'emps' # Added as advised by Yevgeniy
property :employee_id, Serial, :field => 'employee_id' # Added as advised by Bala
property :forename, String
property :surname, String
end
DataMapper.finalize
When I run
employees = Emp.all
employees.inspect
It only returns [ ]
Any idea what am I doing wrong?