Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f4086be
commit 9f29cbe
Showing
1 changed file
with
6 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,12 +102,12 @@ class Event < ActiveRecord::Base | |
|
||
# Return the title but strip out any whitespace. | ||
def title | ||
read_attribute(:title).to_s.strip | ||
super.strip if super | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
botandrose
Contributor
|
||
end | ||
|
||
# Return description without those pesky carriage-returns. | ||
def description | ||
read_attribute(:description).to_s.gsub("\r\n", "\n").gsub("\r", "\n") | ||
super.gsub(/\r\n?/, "\n") if super | ||
end | ||
|
||
def url=(value) | ||
|
@@ -178,15 +178,13 @@ def old? | |
end | ||
|
||
def ongoing? | ||
start_time < Date.today.to_time && end_time && end_time >= Date.today.to_time | ||
return unless end_time && start_time | ||
(start_time..end_time).cover?(Date.today.to_time) | ||
end | ||
|
||
def duration | ||
if end_time && start_time | ||
(end_time - start_time) | ||
else | ||
0 | ||
end | ||
return 0 unless end_time && start_time | ||
(end_time - start_time) | ||
end | ||
end | ||
|
||
|
At some point, I'd be in favor of sanitizing these on save instead of on display.