0.0
No commit activity in last 3 years
No release in over 3 years
Chronorails handles adding virtual attributes to your models (with suitable validations, etc) allowing you to set date and duration fields with natural language text.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

 Project Readme

Chronorails¶ ↑

Chronorails handles adding virtual attributes to your models (with suitable validations, etc) allowing you to set date and duration fields with natural language text.

Installation¶ ↑

gem install chronorails

Usage¶ ↑

For a hypothetical Rails model:

class RomanticMeeting < ActiveRecord::Base
  attr_accessible :length, :start # Integer and DateTime DB fields, respectively

  include Chronorails::ChronicAccessors
  chronic_field :start, :required => true
  chronic_duration_field :length
end

…include the accessors module, and configure Chronorails to start wrap your attributes with either Chronic or Chronic Duration virtual attributes.

Then in your form:

<%= f.text_field :chronic_start %>
<%= f.text_field :chronic_duration_length %>

…you can use the virtual attributes for your fields, entering natural language date and duration information that will be parsed into the regular fields (or will generate validation errors).

The ‘required’ option prevents setting the attributes with blank values; the ‘validates’ option controls the generation of validators (defaults to true) and the ‘accessible’ option controls the generation of Rails 3 ‘attr_accessible’ calls (also defaults to true.)

Testing¶ ↑

git clone git@github.com:simonhildebrandt/chronorails.git
cd chronorails
bundle install
cd spec/dummy
rake db:create
rake db:migrate
rake db:test:prepare
cd -
bundle exec rspec spec

Contribute¶ ↑

  • Fork

  • Hack

  • Test

  • Pull request :)

License¶ ↑

Copyright © 20013 Simon Hildebrandt, released under the MIT license