public
Description: The open source social networking platform in Ruby on Rails from the author of RailsSpace
Homepage: http://insoshi.com
Clone URL: git://github.com/insoshi/insoshi.git
insoshi / app / models / preference.rb
100644 39 lines (33 sloc) 1.211 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# == Schema Information
# Schema version: 28
#
# Table name: preferences
#
# id :integer(11) not null, primary key
# domain :string(255) default(""), not null
# smtp_server :string(255) default(""), not null
# email_notifications :boolean(1) not null
# email_verifications :boolean(1) not null
# created_at :datetime
# updated_at :datetime
# analytics :text
# server_name :string(255)
# app_name :string(255)
# about :text
# demo :boolean(1)
#
 
class Preference < ActiveRecord::Base
  attr_accessible :app_name, :server_name, :domain, :smtp_server,
                  :email_notifications, :email_verifications, :analytics,
                  :about, :demo
 
  validates_presence_of :domain, :if => :using_email?
  validates_presence_of :smtp_server, :if => :using_email?
  
  # Can we send mail with the present configuration?
  def can_send_email?
    not (domain.blank? or smtp_server.blank?)
  end
  
  private
  
    def using_email?
      email_notifications? or email_verifications?
    end
end