On Monday, June 8, 2020 at 11:38:02 AM UTC-7, Robby wrote:
>
> # Gemfile
> gem 'sqlite3', '~> 1.4'
> gem 'sequel', '~> 5.33'
>
>
> # Migration
>
> Sequel.migration do
> up do
> create_table(:users) do
> primary_key :id
> String :first_name
> String :last_name
> String :email
> String :timezone
> Boolean :admin, default: false
> Boolean :enabled, default: true
> DateTime :created_at
> DateTime :updated_at
> end
> end
>
> down do
> drop_table(:users)
> end
> end
>
>
> # User model code
>
> require 'sqlite3'
> require 'sequel'
>
> Sequel.extension :named_timezones
> Sequel.database_timezone = :utc
>
> APPDB = Sequel.connect('sqlite://db/app_development.db')
> Sequel::Model.plugin :timestamps, update_on_create: true
>
> class String
> def sanitize!
> gsub(/[^a-z ]/i, '').split.join('
> ').downcase.split(/\s/).map(&:capitalize).join(' ')
> end
> end
>
> class User < Sequel::Model(APPDB[:users])
> def before_validation
> sanitize_params
> end
>
>
You need to call super to get the default behavior, which sets the
timestamps if using the timestamps plugin.
Thanks,
Jeremy
--
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 view this discussion on the web visit
https://groups.google.com/d/msgid/sequel-talk/36db0969-bafd-4cf2-8db3-883c98c05e08o%40googlegroups.com.