Giter Club home page Giter Club logo

formtastic_datepicker-rails3x's Introduction

Formtastic Datepicker for Rails 3.x

This plugin is based on a blog post by [Grzegorz Brzezinka]:(http://blog.brzezinka.eu/webmaster-tips/ruby/ruby-on-rails-formtastic-jquery-ui-datepicker)

Versions supported

Rails 3

Originally this version of the gem had dependency requirements of Rails 3.1 and above. The requirements have now been relaxed to depend on Rails 3.0 and above.

Formtastic

This gem requires Formtastic 2.0. For a version that supports Formtastic < 2.0, see [formtastic_datepicker]:(https://github.com/kristianmandrup/formtastic_datepicker)

ActiveAdmin

The ActiveAdmin extension should work with ActiveAdmin 0.3.4 (where Formtastic >= 2.0) - note: as of Nov. 25/2011, such a version was found in the active_admin/gregbell master_ branch. ActiveAdmin 0.3.5 and above should likely fulfill this requirement ;)

Conceptual idea

The concept is simple. It adds a new form input to formtastic that can be used like this:

	<% semantic_form_for @master do |f| -%>
		<% f.inputs do -%>
		  <%= f.input :name %>
		  <%= f.input :born, :as => :date_picker %>
		<% end -%>
		<%= f.buttons %>
	<% end -%>

It adds a class onto a normal text input called 'ui-date-picker', and for the parent <li> it adds a class called 'date_picker.' Assuming you have already referenced jquery, and jqueryui in your layout, you can then hook into this with a call from jquery:

	$(document).ready(function(){
		$('input.ui-date-picker').datepicker();
	});

Put this in your application.js or some other js file.

ActiveAdmin integration

In the Gemfile add this gem after ActiveAdmin (gem 'active_admin') to make sure it loads after and overrides/extends ActiveAdmin appropriately.

The ActiveAdmin extensions can be found in lib/active_admin in this project.

Install

Insert into Gemfile:

gem 'formtastic_datepicker-rails3x', :git => 'git://github.com/kristianmandrup/formtastic_datepicker-rails3x.git'

This gem will likely soon be released to RubyGems ;)

Development Environment

We currently support both Rails 2 and Rails 3, under Ruby 1.8.7-ish (and 1.9.2-ish). That means, at a bare minimum, you'll want to set-up two rvm gemsets to run your specs against. So, fork the project on Github, clone it, make some gemsets, run bundler, run your specs and then finally set-up an .rvmrc file that specifies Rails 3 as your default gemset and cd back into that directory to load in the .rvmrc file. Something like this:

cd ~/code/formtastic
rvm gemset create formtastic-rails3
rvm gemset use formtastic-rails3
gem install bundler
bundle install
rake spec
rm Gemfile.lock
rvm gemset create formtastic-rails2
rvm gemset use formtastic-rails2
gem install bundler
RAILS_2=true bundle install
RAILS_2=true rake spec
touch .rvmrc
echo "rvm gemset use formtastic-rails-3" > .rvmrc
cd ~/code/formtastic

Also, most of the testing environment has been copied straight of formtastic, so if something doesn't make sense here, it probably did where I grabbed it from.

Contributors

  • Grzegorz Brzezinka
  • Nik Petersen
  • Alan Harper

formtastic_datepicker-rails3x's People

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

marmolin

formtastic_datepicker-rails3x's Issues

$("#input.ui-date-picker").datepicker is not a function

Tried to use this gem after failing using your other datepicker gems
Uses rails 3.1.1 and formtastic .2.0.2 added this gem to the gemfile (no problem after moving it below the formtastic gem)

Add this to a js file
$(document).ready(function(){
$('input.ui-date-picker').datepicker();
});
as described

triied to use it as
<%= address.input :name ,:as=>:date_picker %>
in a sematic form block
Got the error
$("#input.ui-date-picker").datepicker is not a function
Any suggestion ?

superclass mismatch for class DatePickerInput (TypeError)

Platform: Fedora 16

Rails 3

Formtastic 2

Im trying to install https://github.com/kristianmandrup/formtastic_datepicker-rails3x

After in including the Gem in Gemfile as


gem 'formtastic_datepicker-rails3x', :git => 'git://github.com/kristianmandrup/formtastic_datepicker-rails3x.git'

I tried scaffolding as


rails g scaffold due_date date:date

I got error


/home/sreekeshos/.bundler/ruby/1.8/formtastic_datepicker-rails3x-d66ab9db54bd/lib/formtastic/date_picker_input.rb:2: superclass mismatch for class DatePickerInput (TypeError)
from /home/sreekeshos/.bundler/ruby/1.8/formtastic_datepicker-rails3x-d66ab9db54bd/lib/formtastic_datepicker-rails3x.rb:2:in require' from /home/sreekeshos/.bundler/ruby/1.8/formtastic_datepicker-rails3x-d66ab9db54bd/lib/formtastic_datepicker-rails3x.rb:2 from /usr/lib/ruby/gems/1.8/gems/bundler-1.2.1/lib/bundler/runtime.rb:68:inrequire'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.2.1/lib/bundler/runtime.rb:68:in require' from /usr/lib/ruby/gems/1.8/gems/bundler-1.2.1/lib/bundler/runtime.rb:66:ineach'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.2.1/lib/bundler/runtime.rb:66:in require' from /usr/lib/ruby/gems/1.8/gems/bundler-1.2.1/lib/bundler/runtime.rb:55:ineach'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.2.1/lib/bundler/runtime.rb:55:in require' from /usr/lib/ruby/gems/1.8/gems/bundler-1.2.1/lib/bundler.rb:128:inrequire'
from /home/sreekeshos/Ruby Example/Form sample/form_sample/config/application.rb:7
from /usr/lib/ruby/gems/1.8/gems/railties-3.2.8/lib/rails/commands.rb:24:in require' from /usr/lib/ruby/gems/1.8/gems/railties-3.2.8/lib/rails/commands.rb:24 from script/rails:6:inrequire'
from script/rails:6

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.