2012-08-22 41 views
0

環境:Rails的3.2.3,1.9.3紅寶石-P125Rails的:使用calendar_date_select寶石

我的Gemfile中有以下內容:

gem 'calendar_date_select' 

我的佈局/ application.html.erb有下面的語句(如頭部分的最後一條語句):

<%= calendar_date_select_includes %> 

我通過安裝寶石創業板安裝calendar_date_select 跑耙捆綁:安裝

我閱讀文檔,以及一些在計算器上答覆的,這裏是我最後決定將我的觀點:

<%= form_for(@panel) do |f| %> 
....... 
    Start Date/Time: <%= f.calendar_date_select :start_time, :iso_date => true %> 

我收到以下錯誤消息:

未定義的方法` calendar_date_select'爲#<#:0x007fae3b136938>

任何想法?

回答

0

我已經從使用那個gem切換到只使用具有相同功能的jqueryUI。

enter image description here

爲了做到這一點:

view 
= f.text_field :content_date, id: 'datepicker', size:10 
= f.time_select :content_date, :ignore_date => true # Added later. not shown in screenshot 

Gemfile 
# Nothing - jquery & jqueryUI are now the default. 
# Check web pages to see what really gets included (in the header). 

application.js 
%script 
    # The main code 
    $(function() { 
    $("#datepicker").datepicker(); 
    }); 
    # This makes the pop-up show the actual db date by fixing a format difference. 
    $(function(){ 
    var dateInput = $("#datepicker"); 
    var format = 'yy-mm-dd'; 
    dateInput.datepicker({dateFormat: format}); 
    dateInput.datepicker('setDate', $.datepicker.parseDate(format, dateInput.val())); 
    }); 
+0

好了,現在我可以看到日曆。我怎樣才能顯示時間選擇器? – EastsideDeveloper

+0

啊,是的,我認爲它不會花時間。我會創建一個單獨的字段,等待我找到它,看到我的更新 –

+0

做完這些之後,我有以下內容:3個字段。我點擊第一個,並獲得日期選擇器彈出。我選擇今天的日期,彈出消失,現在我在2012年8月22日在現場。第二個字段需要幾個小時,並且它預先填充了00,並且箭頭選擇了一個小時,然後在新行上有一個冒號(:),後面是第三個字段,預填充了數字29,用一個下拉菜單來選擇多少分鐘。這是我應該期待的行爲嗎?看起來好像您指定的日期格式被忽略。 – EastsideDeveloper

0

使用此代碼,以便在壓延機選擇標籤時

<%= f.calendar_date_select "date", :time => true , :readonly=>true, :popup=>"force" %>