Rails 4 - 引导日期选择器 [英] Rails 4 - Bootstrap date picker

查看:644
本文介绍了Rails 4 - 引导日期选择器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个rails 4应用程序,我使用自举和简单的形式。



我正在尝试遵循本教程,以便我可以有一个点击日期选择器而不是单独的日期,月份和年份字段。



https://learningnewtricks.wordpress.com/2013/07/03/bootstrap-date-picker-on-rails-so-simple/



我已经执行了本教程中的所有步骤,但日期选择器中没有任何变化。



我有:



gemfile:

  gem'bootstrap-datepicker -rails'

application.js

  @importbootstrap-sprockets; 
@importbootstrap;
// = require undercore
// = 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 => 这个项目何时开始?,data-behavior=> 'datepicker',order:[:day,:month,:year]%> 

如何获取日期字段的日历选择器?

解决方案

本教程适用于 Rails 3 ,而您正在使用 Rails 4
主页 https://github.com/Nerian/bootstrap-datepicker-rails表示它与Rails 3资产管道集成(稍后版本的设置稍后提及)。



当您尝试将旧项目迁移到稍后的Rails版本您可能会忽略此处提及的资产管道中的更改。 http ://guides.rubyonrails.org/asset_pipeline.html#upgrading-from-old-versions-of-rails



这可能与您的其他问题有关


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?

解决方案

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.

这篇关于Rails 4 - 引导日期选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆