OSDN Git Service

fix: fetch fail
[pettanr/pettanr.git] / app / models / license.rb
index 009f51e..f0ebd78 100644 (file)
@@ -14,6 +14,18 @@ class License < Peta::SystemResource
   validates :license_group_settings, :boost => {:boost_name => :license_group}
   validates :credit_picture_settings, :boost => {:boost_name => :credit_picture}
   
+  scope :find_index, -> do
+    self.all
+  end
+  
+  scope :find_by_license_group, -> (license_group_id) do 
+    where(license_group_id: license_group_id)
+  end
+  
+  scope :find_by_system_picture, -> (system_picture_id) do 
+    where(system_picture_id: system_picture_id)
+  end
+  
   def overwrite 
   end
   
@@ -30,7 +42,7 @@ class License < Peta::SystemResource
   end
   
   def self.list_by_name name
-    License.find :all, :conditions => ['licenses.name = ?', name], :order => 'licenses.updated_at desc'
+    License.where(name: name).order(updated_at: :desc)
   end
   
   def self.store name, attr
@@ -59,10 +71,9 @@ class License < Peta::SystemResource
   end
   
   def self.export(dt = nil)
-    opt = {}
-    opt.merge!({:conditions => ['updated_at >= ?', dt]}) if dt
-#    opt.merge!({:order => 'name'})
-    License.find(:all, opt)
+    licenses = License.all
+    licenses = licenses.where(['licenses.updated_at >= ?', dt]) if dt
+    licenses.order(:id)
   end
   
 end