Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 7
- Log:
Initial import of RForum 0.2 sources from a downloaded Tarball.
RForum is a Ruby On Rails based forum and mail gateway service.
- Author:
- adh
- Date:
- Sat Jul 22 18:43:13 +0100 2006
- Size:
- 853 Bytes
1 | class Attachment < ActiveRecord::Base |
2 | belongs_to :post |
3 | |
4 | attr_writer :data |
5 | |
6 | include ErrorRaising |
7 | |
8 | def before_save |
9 | self.filename.gsub!(/[^a-z_\.\-0-9]/i, '_') |
10 | end |
11 | |
12 | def after_save |
13 | # Create attachment directory |
14 | begin |
15 | Dir.mkdir(self.dir_path) |
16 | rescue Errno::EEXIST |
17 | end |
18 | # Save uploaded file to attachment directory |
19 | File.open(self.file_path, 'w') do |f| |
20 | f.write(@data) |
21 | end |
22 | end |
23 | |
24 | def after_destroy |
25 | # Delete file |
26 | File.delete self.file_path |
27 | # Delete directory |
28 | Dir.delete self.dir_path |
29 | end |
30 | |
31 | # Returns the directory of this attachment, e.g. /rails/public/attachments/12/ |
32 | def dir_path |
33 | RAILS_ROOT + RForum::CONFIG[:attachment_path] + "/#{self.id}/" |
34 | end |
35 | |
36 | def file_path |
37 | self.dir_path + self.filename |
38 | end |
39 | |
40 | def get_file_content |
41 | File.read self.file_path |
42 | end |
43 | |
44 | |
45 | end |