我有形式:如何在保存到数据库之前更改表单域值?
<%= form_for(@event) do |f| %>
<div class="field">
<%= f.label :title %><br />
<%= f.text_field :title %>
</div>
<div class="field">
<%= f.label :date %><br />
<%= f.text_field :date %>
</div>
<div class="field">
<%= f.label :repeat %><br />
<%= repeat_types = ['none', 'daily', 'monthly', 'yearly']
f.select :repeat, repeat_types %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
我需要保存到“重复”字段改变数据:
:repeat = Event.rule(:date,:repeat)
在哪里,我怎么能保存到数据库之前修改重复场?
什么'Event.repeat'返回?如果不是'self.repeat'? – 2013-04-07 08:12:47
是的,谢谢)我的错误 – Gabi 2013-04-07 08:29:24