Permalink
Browse files

add dependency on validatable gem, use config.gem to depend on other …

…gems. add validation to the settings class
  • Loading branch information...
1 parent c4d10fb commit 2a94954cdbda5fd58b8cb9808453b62f612a75ec @timriley committed Jul 2, 2008
Showing with 15 additions and 9 deletions.
  1. +12 −3 app/models/settings.rb
  2. +3 −0 config/environment.rb
  3. +0 −6 config/initializers/01_requires.rb
View
@@ -1,6 +1,11 @@
class Settings
include Singleton
+ include Validatable
+
+ validates_presence_of :flickr_user_id, :synchronise_tag
+ validates_presence_of :crypted_password, :crypted_password_salt
+ # accessor for the unencrypted password
attr_accessor :password
# this allows us to read and write settings of any name
@@ -20,10 +25,14 @@ def method_missing(method_id, *arguments)
end
def save
- # encrypt the password
- self.crypted_password = self.password unless self.password.blank?
+ if valid?
+ # encrypt the password
+ self.crypted_password = self.password unless self.password.blank?
- File.open("#{Rails.root}/config/config.yml", 'w') { |f| YAML.dump(@raw_tree, f) }
+ File.open("#{Rails.root}/config/config.yml", 'w') { |f| YAML.dump(@raw_tree, f) }
+ else
+ false
+ end
end
protected
View
@@ -25,6 +25,9 @@
# config.gem "bj"
# config.gem "hpricot", :version => '0.6', :source => "http://code.whytheluckystiff.net"
# config.gem "aws-s3", :lib => "aws/s3"
+ config.gem 'bj'
+ config.gem 'validatable'
+ config.gem 'flickraw'
# Only load the plugins named here, in the order given. By default, all plugins
# in vendor/plugins are loaded in alphabetical order.
@@ -1,6 +0,0 @@
-# Gems
-require 'will_paginate'
-require 'bj'
-
-# lib/ files
-# require 'bj_ext'

0 comments on commit 2a94954

Please sign in to comment.