Thank you, Jeremy, this worked.

Happy New Year!

require 'rubygems'
require 'sequel'

DB = Sequel.sqlite

DB.create_table(:posts) do
  primary_key :id
  String :name
  DateTime :updated_at
  DateTime :created_at
  TrueClass :published
end

class Post < Sequel::Model(:posts)
  plugin :timestamps
end

Post.create(:name => "John Smith")

Post.all # => [#<Post @values={:id=>1, :name=>"John
Smith", :updated_at=>nil, :created_at=>2011-12-31 22:34:06
-0800, :published=>nil}>]






On Dec 31, 9:26 am, Jeremy Evans <[email protected]> wrote:
> On Dec 31, 1:15 am, "Andrei (L.A.)" <[email protected]> wrote:
>
>
>
>
>
>
>
>
>
> > Sequel newbie here...
>
> > Is there anything I am missing? Do I need to import plugins separately
> > from 'sequel'? How to do that?
>
> > require 'rubygems'
> > require 'sequel'
>
> > DB = Sequel.sqlite
>
> > DB.create_table(:posts) do
> >   primary_key :id
> >   String :name
> >   DateTime :updated_at
> >   DateTime :created_at
> >   TrueClass :published
> > end
>
> > class Posts < Sequel::Model(:posts)
>
> FYI, Model names should be singular (Post, not Posts).
>
> >   plugin :timestamps
> > end
>
> > Posts.insert(:name => "John Smith")
>
> Posts.insert here is Dataset#insert, which doesn't call the model
> create hooks.  You should use Post.create.  Try that and it should fix
> the issue.
>
> Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sequel-talk?hl=en.

Reply via email to