Permalink
Browse files

Simple content changes in scrabook

  • Loading branch information...
1 parent 882af0c commit 3642892f62c8b1f8f2b07b61bf18047b6d45ec00 @equivalent committed Feb 25, 2013
Showing with 88 additions and 10 deletions.
  1. +3 −0 wisdom_inside/other/readed_articles
  2. +85 −10 wisdom_inside/scraps2/rails
@@ -1,3 +1,6 @@
+http://stackoverflow.com/questions/1208636/rails-include-vs-joins
+http://akitaonrails.com/2008/5/26/rolling-with-rails-2-1-the-first-full-tutorial-part-2#.UStOidHJB6k
+
http://blog.codeclimate.com/blog/2012/10/17/7-ways-to-decompose-fat-activerecord-models/
https://gist.github.com/equivalent/5005568
http://37signals.com/svn/posts/3372-put-chubby-models-on-a-diet-with-concerns
@@ -1,4 +1,66 @@
+# get all classes that are inheriting from this class
+
+ #a/m/document_notification.rb
+ class DocumentNotification < Notification
+ end
+
+ #a/m/notification.rb
+ class Notification < ActiveRecord::Base
+ end
+
+ # console
+ Notification.send :subclasses
+ #=> [DocumentNotification, SomeOtherNotification]
+
+ DocumentNotification.superclass
+ #=> [Notification]
+
+ Notification.superclass
+ #=> [DocumentNotification]
+ # => ActiveRecord::Base
+
+
+date: 2013-02-25
+keys: sti list of classes,
+rails 3.2.12
+
+
+
+#Rails mail mail interceptor
+
+stop sending mails in development
+
+ # lib/development_mail_interceptor.rb
+ class DevelopmentMailInterceptor
+ def self.delivering_email(message)
+ email = LOCAL_CONFIG.try(:[], 'email')
+
+ if email.blank?
+ message.delivery_method :test
+ Rails.logger.warn "No Email address was specified in the app_config.yml"
+ end
+
+ message.to = email
+ message.cc = nil
+ message.bcc = nil
+ development_information = "[ TO: #{message.to} ]"
+ development_information << " [ CC: #{message.cc} ]" if message.cc
+ development_information << " [ BCC: #{message.bcc} ]" if message.bcc
+
+ message.subject = "[Test] #{message.subject} #{development_information}"
+ end
+ end
+
+
+ #config/initializers/setpu_mail.rb
+ ActionMailer::Base.smtp_settings = {
+ :address => "smtp.something.com",
+ :openssl_verify_mode => 'none'
+ }
+
+ ActionMailer::Base.register_interceptor(DevelopmentMailInterceptor) if Rails.env.development?
+
---------------------------------------------------------------------
# scopes
@@ -41,16 +103,29 @@ key : disable dissable sti single table inheritance
# load YAML file config only for development
-~~~ruby
-if Rails.env.development?
- begin
- LOCAL_CONFIG = YAML.load_file("#{Rails.root}/config/local_config.ymlz")[Rails.env] || {}
- rescue
- Rails.logger.warn "No config/local_config.yml not found"
- LOCAL_CONFIG = {}
- end
-end
-~~~
+config
+
+ # config/local_config.rb
+ if Rails.env.development?
+ begin
+ LOCAL_CONFIG = YAML.load_file("#{Rails.root}/config/local_config.yml")[Rails.env] || {}
+ rescue
+ Rails.logger.warn "No config/local_config.yml not found"
+ LOCAL_CONFIG = {}
+ end
+ end
+
+yml file
+
+ # config/initializers/local_config.yml
+ development:
+ email: 'equivalent@eq8.eu'
+
+
+in model
+
+ LOCAL_CONFIG.try(:[], 'email')
+
date: 2013-02-22
keys: enviroment, yaml configuration,

0 comments on commit 3642892

Please sign in to comment.