implemented favorites on post/show page

This commit is contained in:
albert
2011-02-07 18:57:33 -05:00
parent c80df378d8
commit 76a7594a97
16 changed files with 164 additions and 32 deletions

View File

@@ -30,7 +30,7 @@ class Post < ActiveRecord::Base
scope :commented_before, lambda {|date| where("last_commented_at < ?", date).order("last_commented_at DESC")}
scope :available_for_moderation, lambda {where(["id NOT IN (SELECT pd.post_id FROM post_disapprovals pd WHERE pd.user_id = ?)", CurrentUser.id])}
scope :hidden_from_moderation, lambda {where(["id IN (SELECT pd.post_id FROM post_disapprovals pd WHERE pd.user_id = ?)", CurrentUser.id])}
scope :before_id, lambda {|id| where(["posts.id < ?", id])}
scope :before_id, lambda {|id| id.present? ? where(["posts.id < ?", id]) : where("TRUE")}
scope :tag_match, lambda {|query| Post.tag_match_helper(query)}
module FileMethods

View File

@@ -96,11 +96,8 @@ class Upload < ActiveRecord::Base
def merge_tags(post)
post.tag_string += " #{tag_string}"
post.updater_id = uploader_id
post.updater_ip_addr = uploader_ip_addr
post.save
update_attribute(:status, "duplicate: #{post.id}")
raise
end
end
@@ -259,8 +256,8 @@ class Upload < ActiveRecord::Base
self.file_path = temp_file_path
if file.local_path
FileUtils.cp(file.local_path, file_path)
if file.tempfile
FileUtils.cp(file.tempfile.path, file_path)
else
File.open(file_path, 'wb') do |out|
out.write(file.read)