簡體   English   中英

Rails和date_select

[英]Rails and date_select

我正在嘗試將date_select與某些表單一起使用。

<div class="field">
  <%= f.label :begin_date %>
  <br/>
  <%= f.date_select(:begin_date,:start_year => Time.now.year) %>
</div>

通讀文檔,我期望獲得三個選擇標簽。 我得到的是:begin_date(1i),begin_date(2i),begin_date(3i)

如果我將這些包括在模型中:

attr_accessible :begin_date(1i), :begin_date(2i), :begin_date(3i),

IDE不喜歡它。 我究竟做錯了什么? 另外,是否有一個日期選擇方法可以在單個標記中返回值,而不是3?

您只需執行attr_accessible :begin_date ,它將日期組件組合在一起,為您提供單個Date值。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM