Zeit als Sek statt Std. zu speicher macht zu viele Probleme.

pull/6827/head
Felix Schäfer 14 years ago
parent c868c54796
commit 675fcf3a19
  1. 1
      app/controllers/meetings_controller.rb
  2. 9
      app/models/meeting.rb
  3. 2
      app/views/meetings/index.html.erb
  4. 2
      db/migrate/20110106210555_create_meetings.rb

@ -66,5 +66,6 @@ class MeetingsController < ApplicationController
def convert_params
params[:meeting][:start_time] = Date.parse(params[:meeting].delete(:start_date)) + params[:meeting].delete(:"start_time(4i)").to_i.hours + params[:meeting].delete(:"start_time(5i)").to_i.minutes
params[:meeting][:participants] = (params[:meeting_participant_users].collect{|i| @meeting.participants.find_or_initialize_by_user_id(i)} if params[:meeting_participant_users].present?) || []
params[:meeting][:duration] = params[:meeting][:duration].to_hours
end
end

@ -14,15 +14,6 @@ class Meeting < ActiveRecord::Base
start_time.to_date if start_time.present?
end
# store the duration as seconds internally
def duration
self[:duration]/3600.0 if self[:duration].present?
end
def duration=(h)
self[:duration] = ((h.is_a?(String) ? h.to_hours : h)*3600).round if h.present?
end
protected
def after_initialize

@ -13,7 +13,7 @@
<div class="meeting" id="meeting-#{meeting.id}" >
<h3><%= format_time meeting.start_time %>: <%= link_to h(meeting.title), :controller => 'meetings', :action => 'show', :id => meeting %></h3>
<p class="author"><%= authoring meeting.created_at, meeting.author %></p>
<p><strong><%= l(:field_location) %></strong>: <%=h meeting.location %> - <strong><%= l(:field_duration) %></strong>: <%= l_hours(@meeting.duration) %></p>
<p><strong><%= l(:field_location) %></strong>: <%=h meeting.location %> - <strong><%= l(:field_duration) %></strong>: <%= l_hours(meeting.duration) %></p>
<p><strong><%= l(:field_participants) %></strong> (<%= meeting.participants.count %>): <%= meeting.participants.join(", ") %></p>
</div>
<% end -%>

@ -6,7 +6,7 @@ class CreateMeetings < ActiveRecord::Migration
t.column :project_id, :integer
t.column :location, :string
t.column :start_time, :datetime
t.column :duration, :integer # duration in seconds
t.column :duration, :float
t.timestamps
end

Loading…
Cancel
Save