I have been trying sequel for the past few days and I'm trying to set up 
the :timestamps plugin to add a created_at and updated_at to my tables 
whenever a new record is created or updated (the columns exist obviously in 
the table). This would be my migration:

01_example.rb

Sequel.migration do
>   change do
>     create_table :users do
>       primary_key :id
>       String :username, :null => false
>       String :name
>       String :email, :null => false
>     end
>   end
> end


02_example.rb

Sequel.migration do
>   change do
>     add_column :users, :created_at, DateTime
>     add_column :users, :updated_at, DateTime
>   end
> end


And I have the following config.ru

require 'rubygems'
> require 'bundler/setup'
> Bundler.require :default, ENV['RACK_ENV']
>
> use Rack::Timeout
> use Rack::Rewrite do
>   r301 %r{.*}, "http://#{ENV['CANONICAL_URL']}$&", :if => Proc.new { 
> |rack_env|
>     ENV['RACK_ENV'] == :production.to_s && rack_env['SERVER_NAME'] != 
> ENV['CANONICAL_URL']
>   }
>   r301 %r{^(.+)/$}, '$1'
> end
> DATABASE.disconnect if defined?(DATABASE)
> if ENV['DATABASE_URL']
>   db_config = URI.parse ENV['DATABASE_URL']
> else
>   db_config = 
> YAML.load(ERB.new(File.read('config/database.yml')).result)[ENV['RACK_ENV']]
> end
> DATABASE = Sequel.connect db_config
> Sequel::Model.plugin :timestamps, :create => :created_on, :update => 
> :updated_on, :update_on_create => true
> #Sequel::Model.plugin :auto_validations, :not_null => :presence
> require File.expand_path('../application/api', __FILE__)
> run Pulsr::API


And my model looks something like this:

> module Pulsr
>   module Models
>     class User < Sequel::Model
>     end
>   end
> end



Whenever I create a new record with Pulsr::Models::User.create(:username => 
params[:username], :email => params[:email], :name => params[:name]), the 
updated_at and created_at are null. Does anyone know what is going on ?

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to