问题
I have a rails 4 app which I use with bootstrap and simple form.
I'm trying to follow this tutorial so that i can have a single click date picker instead of separate date, month and year fields.
https://learningnewtricks.wordpress.com/2013/07/03/bootstrap-date-picker-on-rails-so-simple/
I have implemented all of the steps in this tutorial, but nothing changes in the date picker.
I have:
gemfile:
gem 'bootstrap-datepicker-rails'
application.js
@import "bootstrap-sprockets";
@import "bootstrap";
//= require underscore
//= require gmaps/google
//= require jquery
//= require bootstrap
//= require bootstrap-sprockets
//= require bootstrap-slider
//= require jquery_ujs
//= require bootstrap-datepicker
//= require_tree .
application.css.scss
*= require_framework_and_overrides.css.scss
*= require bootstrap-datepicker
*= require_self
*= require_tree .
view (html.erb)
<%= f.date_select :start_date, :label => "When does this project begin?", 'data-behaviour' => 'datepicker', order: [:day, :month, :year] %>
How do you get a calendar selector for the date field?
回答1:
The tutorial is for Rails 3 while you are using Rails 4. The homepage https://github.com/Nerian/bootstrap-datepicker-rails says that it integrates with Rails 3 asset pipeline (settings for later versions are mentioned later).
As you are trying to migrate your old project to the later Rails version, you probably disregard changes in the asset pipeline as mentioned here http://guides.rubyonrails.org/asset_pipeline.html#upgrading-from-old-versions-of-rails
This possibly relates to your other questions as well.
来源:https://stackoverflow.com/questions/33852687/rails-4-bootstrap-date-picker