1) You must install the adapter.
2) Add requires require "rubigems" require 'data_mapper' 3) Configure my sql
DataMapper.setup(:default, 'mysql://localhost/the_database_name')
or
DataMapper.mysql(:host xxxx, :user xxxx, :password xxxx, :database xxxx)
4) Create model objects, for example:
class Post include DataMapper::Resource property :id, Serial # An auto-increment integer key property :title, String # A varchar type string, for short strings property :body, Text # A text block, for longer string data. property :created_at, DateTime # A DateTime, for any date you might like. end
If you have any doubts, you can check this link: http://datamapper.org/getting-started
Jairo source share