TimeLogControlle的 new 方法中创建 TimeEntry 时传了一堆参数但是 TimeEntry 类 的 initialize 方法好像并没有对参数进行处理,很迷惑,有知道的或者我哪里搞错了可以指点一下吗,不胜感激~
def new
@time_entry ||= TimeEntry.new(:project => @project, :issue => @issue, :user => User.current, :spent_on => User.current.today)
@time_entry.safe_attributes = params[:time_entry]
end
def initialize(attributes=nil, *args)
super
if new_record? && self.activity.nil?
if default_activity = TimeEntryActivity.default
self.activity_id = default_activity.id
end
self.hours = nil if hours == 0
end
end