pool views

This commit is contained in:
albert
2011-02-25 17:41:00 -05:00
parent f48000a8b5
commit 6d0157265c
39 changed files with 1213 additions and 674 deletions

View File

@@ -7,10 +7,14 @@ class Pool < ActiveRecord::Base
before_validation :normalize_name
before_validation :initialize_creator, :on => :create
after_save :create_version
attr_accessible :name, :description, :post_ids, :is_active
attr_accessible :name, :description, :post_ids, :is_active, :post_id_array
def self.name_to_id(name)
select_value_sql("SELECT id FROM pools WHERE name = ?", name.downcase)
if name =~ /^\d+$/
name.to_i
else
select_value_sql("SELECT id FROM pools WHERE name = ?", name.downcase)
end
end
def self.create_anonymous(creator, creator_ip_addr)
@@ -61,6 +65,11 @@ class Pool < ActiveRecord::Base
@post_id_array ||= post_ids.scan(/\d+/).map(&:to_i)
end
def post_id_array=(array)
self.post_ids = array.join(" ")
clear_post_id_array
end
def clear_post_id_array
@post_id_array = nil
end

View File

@@ -76,11 +76,19 @@ class Post < ActiveRecord::Base
end
def medium_file_url
"/data/medium/#{file_path_prefix}#{md5}.jpg"
if has_medium?
"/data/medium/#{file_path_prefix}#{md5}.jpg"
else
file_url
end
end
def large_file_url
"/data/large/#{file_path_prefix}#{md5}.jpg"
if has_large?
"/data/large/#{file_path_prefix}#{md5}.jpg"
else
medium_file_url
end
end
def preview_file_url