implemented favorites on post/show page
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user