Rails 4 - Bootstrap date picker

匿名 (未验证) 提交于 2019-12-03 01:29:01

问题:

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.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!