This is a simple gem for Active Admin that just adds support for Time picker.
It supports both ActiveRecord for relational databases and Mongoid for MongoDB schemaless database.
For Date/Time picker widget, see just-datetime-picker.
Here comes a quick code sample. Sorry, currently no detailed docs.
That should create nice date/time picker for User#notify_at.
Associated column in the DB should can have type of :time. It has to be nullable.
To delete previously stored time just make all fields blank (hour and minute).
class CreateUsers < ActiveRecord::Migration def change create_table :users do |t| t.time :notify_at # You can also use :integer with :limit => 6 t.timestamps end end end
class User < ActiveRecord::Base just_define_time_picker :notify_at, :add_to_attr_accessible => true validates :notify_at, :presence => true end
class User include Mongoid::Document field :notify_at, type: Time just_define_time_picker :notify_at, :add_to_attr_accessible => true end
You must place “mongoid” gem BEFORE “just-time-picker” gem in your Gemfile!
ActiveAdmin.register User do form do |f| f.inputs do f.input :notify_at, :as => :just_time_picker end f.buttons end end
The gems are hosted at Rubygems.org. Make sure you’re using the latest version of rubygems:
$ gem update --system
Then you can install the gem as follows:
$ gem install just-time-picker
Add to your Gemfile:
gem "just-time-picker"
and then type:
bundle install
The source code is available at github.com/saepia/just-time-picker. You can either clone the git repository or download a tarball or zip file. Once you have the source, you can unpack it and use from wherever you downloaded.
If you use Rails >= 3.1 AND ActiveAdmin >= 0.5.0 just add this line to active_admin.css.scss
@import "just_time_picker/base";
Otherwise, just manually append the code from this file to your CSS stylesheet.
In ActiveAdmin 0.4.x you must strip body.active_admin from CSS declarations.
en, pl, zh-CN, fr
Code was tested with:
-
ActiveAdmin 0.4.4, 0.5.0 and 0.5.1,
-
formtastic 2.2.1,
-
Ruby on Rails 3.2.8, 3.2.11.
This code is licensed under GPLv3.
-
Added xmlschema and iso8601 methods to Time class (Marcin Lewandowski)
-
Initial release based on just-datetime-picker 0.0.6 (Marcin Lewandowski)