我有在数据库中存储日期的要求。但我只想允许用户更改选择日期的日期。
就像他们只能选择 Monday , Tuesday 等,并且基于此我想调整数据库中的日期。
为了满足要求,我正在尝试以下代码,但它正在抛出错误
<%= f.datetime_select :published_at.to_time.strftime("%a") %>
以下是错误信息:
NoMethodError in Articles#new 
Showing C:/Users/huzaifa.gain/My Documents/Aptana Studio 3 Workspace/blog/app/views/articles/_form.html.erb where line #32 raised: 
undefined method `to_time' for :published_at:Symbol 
Extracted source (around line #32): 
29:   </div>
30:   <div class="field">
31:     <%= f.label :published_at %><br />
32:     <%= f.datetime_select :published_at.to_time.strftime("%a") %>
33:     <%= f.select :published_at, Date::DAYNAMES.zip((0..6).to_a) %> 
34: 
35: