Created
March 12, 2012 07:25
-
-
Save marshluca/2020451 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
From d3bb57d8e3974f2f6101184aafe4f4841b7af3f4 Mon Sep 17 00:00:00 2001 | |
From: Lin Zhang <[email protected]> | |
Date: Fri, 2 Mar 2012 11:36:06 +0800 | |
Subject: [PATCH] defind method Wallpaper.upload | |
--- | |
app/models/wallpaper.rb | 12 ++++++++++-- | |
1 files changed, 10 insertions(+), 2 deletions(-) | |
diff --git a/app/models/wallpaper.rb b/app/models/wallpaper.rb | |
index 4fc3759..9dceff5 100644 | |
--- a/app/models/wallpaper.rb | |
+++ b/app/models/wallpaper.rb | |
@@ -115,9 +115,17 @@ class Wallpaper < ActiveRecord::Base | |
File.join("/share/datas/shares/wallpapers", "#{path}.#{style}.#{formatt}") | |
end | |
- # iphone 640x960 | |
- # android 480x800 | |
+ class << self | |
+ def upload(name, category_id, file, account_id=1, options={}) | |
+ wallpaper = self.new(:name => name, :category_id => category_id, :file => file, :account_id => account_id) | |
+ if wallpaper.save | |
+ user.syncronize(wallpaper, options) if options[:sync] | |
+ end | |
+ end | |
+ end | |
end | |
$model_to_section_ids = $sections.inject({}) {|hash, item| hash[item[0].camelize.constantize] = item[1]; hash } | |
+# iphone 640x960 | |
+# android 480x800 | |
-- | |
1.7.5.4+GitX |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment