active_mailer 0.0.9 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 99e1d029544140a5c0694c8cdec3e7b64caef636
4
+ data.tar.gz: 58aa481703fe2dd3ac5a33c7771ac394f1e58a37
5
+ SHA512:
6
+ metadata.gz: 614db7b69f763e6b4a04bad6d670bdd6fb0830a24c728b6cd2a55b2c1869cbfc75b21e8be1c07c04a2796794e4f1e252e32b0ce4cadc1b19d7ce0d4071db9ac8
7
+ data.tar.gz: ec33f72e5d074745554c8843cd129b3e70da5c05741fa60ce6dfb3d6d726525c490c0864bc1dbb6bd9eb8822e98483eef62e3822c869e90b4b6bea15e81b863e
data/.gitignore CHANGED
@@ -5,35 +5,10 @@
5
5
  .\#*
6
6
  .bundle
7
7
  .DS_Store
8
- .svn
9
8
  insight.sqlite
10
- app/assets/stylesheets/.sass-cache/*
11
- config/*.sphinx.conf
12
- coverage
13
- db/*.bkp
14
- db/deep_test*
15
- db/*.sqlite3
16
- db/*sphinx
17
- log/test
18
9
  log/*.log
19
- log/*.pid
20
- log/culerity_page_errors
21
- public/system
22
- public/p/*
23
- public/culerity_page_errors
24
- public/javascripts/all.js
25
- public/stylesheets/all.css
26
- public/images/upload
27
- public/data
28
10
  vendor/bundle
29
11
  test/log
30
12
  tmp
31
- coverage.data
32
- rerun.txt
33
- test/fixtures/vcr_cassettes
34
- features/cassettes
35
- coverage
36
- bin
37
- repos
38
- test/fixtures/repos
39
- *.gem
13
+ Gemfile.lock
14
+ pkg/
@@ -1,15 +1,18 @@
1
- = 0.0.9
1
+ ### 0.0.10
2
+ * Update project to modern Ruby standards.
3
+
4
+ ### 0.0.9
2
5
  * okay, this time we are totally setting the headers correctly
3
6
 
4
- = 0.0.8
7
+ ### 0.0.8
5
8
  * do not coerce headers
6
9
 
7
- = 0.0.7
10
+ ### 0.0.7
8
11
  * support for setting custom email headers. Give us the hassssh.
9
12
 
10
- = 0.0.6
13
+ ### 0.0.6
11
14
  * support for setting layouts
12
15
 
13
- = 0.0.5
16
+ ### 0.0.5
14
17
  * Fixed bug where the subject was not being set correctly.
15
18
  * The ActionMailer object used behind the scenese is now available through #mailer
data/Gemfile CHANGED
@@ -1,15 +1,3 @@
1
- source "http://rubygems.org"
1
+ source "https://rubygems.org"
2
2
 
3
3
  gemspec
4
-
5
- gem "rails", "=3.2.1"
6
- gem "capybara", ">= 0.4.0"
7
- gem "sqlite3"
8
-
9
- gem "pry"
10
- gem "pry-rails"
11
- gem "pry-nav"
12
- gem "pry-stack_explorer"
13
-
14
- gem "wrong"
15
- gem "factory_girl"
data/README.md ADDED
@@ -0,0 +1,77 @@
1
+ # ActiveMailer
2
+
3
+ Email needs to have somewhere to put the business logic surrounding it, and
4
+ the controller is not the place for that.
5
+
6
+ See the disagreement:
7
+ * http://www.robbyonrails.com/articles/2009/11/16/sending-email-controllers-versus-models
8
+ * http://twitter.com/dhh/status/5769040367
9
+ * http://twitter.com/dhh/status/5769698185
10
+ * http://www.loudthinking.com/posts/43-think-of-emails-as-views-delivered-through-smtp
11
+
12
+
13
+ ## Installation
14
+
15
+ 1. Add `gem "active_mailer"` to your `Gemfile` and run `bundle install`
16
+
17
+ 2. Run `rails generate active_mailer:install`
18
+
19
+ 3. Run `rake db:migrate`
20
+
21
+
22
+ ## Basic Usage
23
+
24
+ There's only a partial generator. In the mean time, making a new ActiveMailer class can be done like this.
25
+
26
+ 1. Run `rails generate model --no-migration --parent ActiveMailer::Base FooEmail`, you can pass any additional columns just like you would for a normal `generate model`.
27
+
28
+ 2. Run `rails generate active_model:migration FooEmail`
29
+
30
+ 3. Make the template for your email (in this case called `foo_email.rb`) in `app/views/active_mailer/base/default_action_mailer`
31
+
32
+ You're ready! You can send your email by making an instance of `FooEmail`, setting the appropriate details, and calling `send!`.
33
+
34
+ ```ruby
35
+ > f = FooEmail.new(:subject => "My Awesome Email", :sender => "noreply@example.com",
36
+ > :recipients => "test@example.com")
37
+ => #<FooEmail id: nil, blahblahblah>
38
+
39
+ > f.send!
40
+ => true
41
+ ```
42
+
43
+ ## Advanced Usage
44
+
45
+ If your email is always going to have the same subject, sender, bcc, etc, then
46
+ you can set those in the ActiveMailer object. Remember that it's really just
47
+ an ActiveRecord object, so you can do anything in this class you can do in
48
+ ActiveRecord.
49
+
50
+ Here's an example of using ActiveRecord associations to make sure there's a
51
+ user for the email. It also includes setting the subject and sender by
52
+ default.
53
+
54
+ ```ruby
55
+ class BeerEmail < ActiveMailer::Base
56
+ belongs_to :user
57
+
58
+ validates_presence_of :user
59
+
60
+ def after_initialize
61
+ self.subject = "It's Beer O'Clock"
62
+ self.sender = "itstime@beeroclock.com"
63
+ end
64
+ end
65
+ ```
66
+
67
+ ## Contributing
68
+
69
+ [Bugs/Feature](http://www.pivotaltracker.com/projects/14211)
70
+
71
+
72
+ ## Authors
73
+
74
+ Matt Gordon
75
+
76
+
77
+ Copyright (c) 2009-2015 [Expected Behavior, LLC], released under the MIT license
data/Rakefile CHANGED
@@ -1,15 +1,8 @@
1
- # encoding: UTF-8
2
- require 'rubygems'
3
- begin
4
- require 'bundler/setup'
5
- rescue LoadError
6
- puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
7
- end
8
-
1
+ require 'bundler/setup'
9
2
  require 'rake'
10
3
  require 'rdoc/task'
11
-
12
4
  require 'rake/testtask'
5
+ require 'bundler/gem_tasks'
13
6
 
14
7
  Rake::TestTask.new(:test) do |t|
15
8
  t.libs << 'lib'
@@ -1,22 +1,29 @@
1
+ $:.push File.expand_path("../lib", __FILE__)
2
+ require "active_mailer/version"
3
+
1
4
  # Provide a simple gemspec so you can easily use your enginex
2
5
  # project in your rails apps through git.
3
6
  Gem::Specification.new do |s|
4
7
  s.name = "active_mailer"
5
8
  s.summary = "Adds model-level validation to emails."
6
- s.description = "Application that have complext email sending logic have DRYness problems. ActiveMailersolves that by making a legitimate email model where all sending logic belongs. Also capable of acting as an audit trail for email sending."
9
+ s.description = "Applications that have complex email sending logic have DRYness problems. ActiveMailer solves that by making a legitimate email model where all sending logic belongs. It is also capable of acting as an audit trail for email sending."
7
10
  s.authors = ["Matt Gordon"]
8
11
  s.email = 'support@expectedbehavior.com'
9
12
  s.files = Dir["{app,lib,config}/**/*"] + ["MIT-LICENSE", "Rakefile", "Gemfile", "README.rdoc"]
10
- s.version = "0.0.9"
13
+ s.version = ActiveMailer::VERSION
11
14
  s.homepage =
12
15
  'https://github.com/expectedbehavior/active_mailer'
13
16
 
14
17
 
15
18
  s.required_rubygems_version = "> 1.3.6"
16
19
 
17
- s.add_dependency "activesupport" , "~> 3.2"
18
20
  s.add_dependency "rails" , "~> 3.2"
19
21
 
22
+ s.add_development_dependency(%q<rake>, [">= 0"])
23
+ s.add_development_dependency(%q<wrong>, ["~> 0.7.0"])
24
+ s.add_development_dependency(%q<sqlite3>, [">= 1.3.5"])
25
+ s.add_development_dependency(%q<test-unit>, ["~> 3.0.0"])
26
+
20
27
  s.files = `git ls-files`.split("\n")
21
28
  s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
22
29
  s.require_path = 'lib'
@@ -1,8 +1,3 @@
1
- # require 'email_user'
2
- # require 'email_user_association'
3
- # require 'action_controller'
4
- # require 'application_helper'
5
- # require 'action_controller/url_writer'
6
1
  module ActiveMailer #:nodoc:
7
2
  class Base < ActiveRecord::Base
8
3
  self.abstract_class = true
@@ -167,7 +162,6 @@ module ActiveMailer #:nodoc:
167
162
  attachments_to_set = (options[:attachments] || [])
168
163
  options.keys.each do |k|
169
164
  self.instance_eval("@#{k.to_s} = options[k]") if options[k]
170
- # instance_variable_set(k.to_s, options[k])
171
165
  end
172
166
 
173
167
  attachments_to_set.each do |att|
@@ -189,7 +183,7 @@ module ActiveMailer #:nodoc:
189
183
  end
190
184
 
191
185
  def default_email_method_name
192
- "#{self.name.underscore}"
186
+ name.underscore
193
187
  end
194
188
  end
195
189
  end
@@ -0,0 +1,3 @@
1
+ module ActiveMailer
2
+ VERSION = "0.0.10"
3
+ end
@@ -1,13 +1,13 @@
1
1
  class <%= migration_class_name %> < ActiveRecord::Migration
2
2
  def change
3
- create_table :<%= table_name %> do |t|
3
+ create_active_mailer_table :<%= table_name %> do |t|
4
4
  <% attributes.each do |attribute| -%>
5
5
  t.<%= attribute.type %> :<%= attribute.name %><%= attribute.inject_options %>
6
6
  <% end -%>
7
7
 
8
8
  t.integer :sender_id
9
9
  t.timestamp :sent_at
10
- t.string :subject
10
+ t.string :subject
11
11
 
12
12
  t.timestamps
13
13
  end
@@ -25,7 +25,10 @@ class ActiveMailerTest < ActiveSupport::TestCase
25
25
 
26
26
  test "sends with correct layout" do
27
27
  InvitationEmail.layout "email"
28
- email = create(:invitation_email)
28
+ email = InvitationEmail.new(:sender => "spammy@example.com",
29
+ :recipients => ["takesit@upemail.com", nil],
30
+ :subject => "YOU GUYS!"
31
+ )
29
32
  assert { email.send! }
30
33
  actual_layout = ActiveMailer::Base::DefaultActionMailer.instance_variable_get("@_layout")
31
34
  assert { "email" == actual_layout }
@@ -1,8 +1,7 @@
1
1
  PATH
2
- remote: /Users/esquivalient/code/active_mailer
2
+ remote: ../../..
3
3
  specs:
4
- active_mailer (0.0.5)
5
- activesupport (~> 3.2)
4
+ active_mailer (0.0.9)
6
5
  rails (~> 3.2)
7
6
 
8
7
  GEM
data/test/test_helper.rb CHANGED
@@ -4,9 +4,7 @@ ENV["RAILS_ENV"] = "test"
4
4
  require File.expand_path("../fixtures/dummyapp_rails_3.2/config/environment.rb", __FILE__)
5
5
  require "rails/test_help"
6
6
 
7
- require "factory_girl"
8
- include FactoryGirl::Syntax::Methods
9
- FactoryGirl.find_definitions
7
+ require "wrong"
10
8
 
11
9
  # ActionMailer::Base.delivery_method = :test
12
10
  # ActionMailer::Base.perform_deliveries = true
@@ -14,11 +12,6 @@ FactoryGirl.find_definitions
14
12
 
15
13
  # Rails.backtrace_cleaner.remove_silencers!
16
14
 
17
- # Configure capybara for integration testing
18
- # require "capybara/rails"
19
- # Capybara.default_driver = :rack_test
20
- # Capybara.default_selector = :css
21
-
22
15
  # Run any available migration
23
16
  ActiveRecord::Migrator.migrate File.expand_path("../fixtures/dummyapp_rails_3.2/db/migrate/", __FILE__)
24
17
 
metadata CHANGED
@@ -1,62 +1,98 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_mailer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
5
- prerelease:
4
+ version: 0.0.10
6
5
  platform: ruby
7
6
  authors:
8
7
  - Matt Gordon
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-06-17 00:00:00.000000000 Z
11
+ date: 2015-06-25 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
- name: activesupport
14
+ name: rails
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
19
  version: '3.2'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ~>
24
+ - - "~>"
28
25
  - !ruby/object:Gem::Version
29
26
  version: '3.2'
30
27
  - !ruby/object:Gem::Dependency
31
- name: rails
28
+ name: rake
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ~>
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
- version: '3.2'
38
- type: :runtime
33
+ version: '0'
34
+ type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ~>
38
+ - - ">="
44
39
  - !ruby/object:Gem::Version
45
- version: '3.2'
46
- description: Application that have complext email sending logic have DRYness problems.
47
- ActiveMailersolves that by making a legitimate email model where all sending logic
48
- belongs. Also capable of acting as an audit trail for email sending.
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: wrong
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.7.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.7.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: sqlite3
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 1.3.5
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: 1.3.5
69
+ - !ruby/object:Gem::Dependency
70
+ name: test-unit
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 3.0.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 3.0.0
83
+ description: Applications that have complex email sending logic have DRYness problems.
84
+ ActiveMailer solves that by making a legitimate email model where all sending logic
85
+ belongs. It is also capable of acting as an audit trail for email sending.
49
86
  email: support@expectedbehavior.com
50
87
  executables: []
51
88
  extensions: []
52
89
  extra_rdoc_files: []
53
90
  files:
54
- - .gitignore
55
- - ChangeLog.md
91
+ - ".gitignore"
92
+ - CHANGELOG.md
56
93
  - Gemfile
57
- - Gemfile.lock
58
94
  - MIT-LICENSE
59
- - README
95
+ - README.md
60
96
  - Rakefile
61
97
  - active_mailer.gemspec
62
98
  - app/models/active_mailer/base.rb
@@ -64,6 +100,7 @@ files:
64
100
  - app/models/active_mailer/email_user_association.rb
65
101
  - lib/active_mailer.rb
66
102
  - lib/active_mailer/engine.rb
103
+ - lib/active_mailer/version.rb
67
104
  - lib/generators/active_mailer/install/install_generator.rb
68
105
  - lib/generators/active_mailer/install/templates/migration.rb
69
106
  - lib/generators/active_mailer/migration/migration_generator.rb
@@ -4484,30 +4521,28 @@ files:
4484
4521
  - test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/specifications/tzinfo-0.3.35.gemspec
4485
4522
  - test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/specifications/uglifier-1.3.0.gemspec
4486
4523
  - test/fixtures/dummyapp_rails_3.2/vendor/plugins/.gitkeep
4487
- - test/support/integration_case.rb
4488
4524
  - test/test_helper.rb
4489
4525
  homepage: https://github.com/expectedbehavior/active_mailer
4490
4526
  licenses: []
4527
+ metadata: {}
4491
4528
  post_install_message:
4492
4529
  rdoc_options: []
4493
4530
  require_paths:
4494
4531
  - lib
4495
4532
  required_ruby_version: !ruby/object:Gem::Requirement
4496
- none: false
4497
4533
  requirements:
4498
- - - ! '>='
4534
+ - - ">="
4499
4535
  - !ruby/object:Gem::Version
4500
4536
  version: '0'
4501
4537
  required_rubygems_version: !ruby/object:Gem::Requirement
4502
- none: false
4503
4538
  requirements:
4504
- - - ! '>'
4539
+ - - ">"
4505
4540
  - !ruby/object:Gem::Version
4506
4541
  version: 1.3.6
4507
4542
  requirements: []
4508
4543
  rubyforge_project:
4509
- rubygems_version: 1.8.23
4544
+ rubygems_version: 2.4.8
4510
4545
  signing_key:
4511
- specification_version: 3
4546
+ specification_version: 4
4512
4547
  summary: Adds model-level validation to emails.
4513
4548
  test_files: []
data/Gemfile.lock DELETED
@@ -1,154 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- active_mailer (0.0.9)
5
- activesupport (~> 3.2)
6
- rails (~> 3.2)
7
-
8
- GEM
9
- remote: http://rubygems.org/
10
- specs:
11
- actionmailer (3.2.1)
12
- actionpack (= 3.2.1)
13
- mail (~> 2.4.0)
14
- actionpack (3.2.1)
15
- activemodel (= 3.2.1)
16
- activesupport (= 3.2.1)
17
- builder (~> 3.0.0)
18
- erubis (~> 2.7.0)
19
- journey (~> 1.0.1)
20
- rack (~> 1.4.0)
21
- rack-cache (~> 1.1)
22
- rack-test (~> 0.6.1)
23
- sprockets (~> 2.1.2)
24
- activemodel (3.2.1)
25
- activesupport (= 3.2.1)
26
- builder (~> 3.0.0)
27
- activerecord (3.2.1)
28
- activemodel (= 3.2.1)
29
- activesupport (= 3.2.1)
30
- arel (~> 3.0.0)
31
- tzinfo (~> 0.3.29)
32
- activeresource (3.2.1)
33
- activemodel (= 3.2.1)
34
- activesupport (= 3.2.1)
35
- activesupport (3.2.1)
36
- i18n (~> 0.6)
37
- multi_json (~> 1.0)
38
- arel (3.0.0)
39
- binding_of_caller (0.7.1)
40
- debug_inspector (>= 0.0.1)
41
- builder (3.0.0)
42
- capybara (1.1.2)
43
- mime-types (>= 1.16)
44
- nokogiri (>= 1.3.3)
45
- rack (>= 1.0.0)
46
- rack-test (>= 0.5.4)
47
- selenium-webdriver (~> 2.0)
48
- xpath (~> 0.1.4)
49
- childprocess (0.3.1)
50
- ffi (~> 1.0.6)
51
- coderay (1.0.8)
52
- debug_inspector (0.0.2)
53
- diff-lcs (1.1.3)
54
- erubis (2.7.0)
55
- factory_girl (4.2.0)
56
- activesupport (>= 3.0.0)
57
- ffi (1.0.11)
58
- hike (1.2.1)
59
- i18n (0.6.0)
60
- journey (1.0.1)
61
- json (1.6.5)
62
- mail (2.4.1)
63
- i18n (>= 0.4.0)
64
- mime-types (~> 1.16)
65
- treetop (~> 1.4.8)
66
- method_source (0.8.1)
67
- mime-types (1.17.2)
68
- multi_json (1.0.4)
69
- nokogiri (1.5.0)
70
- polyglot (0.3.3)
71
- predicated (0.2.6)
72
- pry (0.9.12)
73
- coderay (~> 1.0.5)
74
- method_source (~> 0.8)
75
- slop (~> 3.4)
76
- pry-nav (0.2.3)
77
- pry (~> 0.9.10)
78
- pry-rails (0.2.2)
79
- pry (>= 0.9.10)
80
- pry-stack_explorer (0.4.9)
81
- binding_of_caller (>= 0.7)
82
- pry (~> 0.9.11)
83
- rack (1.4.1)
84
- rack-cache (1.1)
85
- rack (>= 0.4)
86
- rack-ssl (1.3.2)
87
- rack
88
- rack-test (0.6.1)
89
- rack (>= 1.0)
90
- rails (3.2.1)
91
- actionmailer (= 3.2.1)
92
- actionpack (= 3.2.1)
93
- activerecord (= 3.2.1)
94
- activeresource (= 3.2.1)
95
- activesupport (= 3.2.1)
96
- bundler (~> 1.0)
97
- railties (= 3.2.1)
98
- railties (3.2.1)
99
- actionpack (= 3.2.1)
100
- activesupport (= 3.2.1)
101
- rack-ssl (~> 1.3.2)
102
- rake (>= 0.8.7)
103
- rdoc (~> 3.4)
104
- thor (~> 0.14.6)
105
- rake (0.9.2.2)
106
- rdoc (3.12)
107
- json (~> 1.4)
108
- ruby2ruby (2.0.3)
109
- ruby_parser (~> 3.1)
110
- sexp_processor (~> 4.0)
111
- ruby_parser (3.1.1)
112
- sexp_processor (~> 4.1)
113
- rubyzip (0.9.6.1)
114
- selenium-webdriver (2.19.0)
115
- childprocess (>= 0.2.5)
116
- ffi (~> 1.0.9)
117
- multi_json (~> 1.0.4)
118
- rubyzip
119
- sexp_processor (4.1.5)
120
- slop (3.4.3)
121
- sprockets (2.1.2)
122
- hike (~> 1.2)
123
- rack (~> 1.0)
124
- tilt (~> 1.1, != 1.3.0)
125
- sqlite3 (1.3.5)
126
- thor (0.14.6)
127
- tilt (1.3.3)
128
- treetop (1.4.10)
129
- polyglot
130
- polyglot (>= 0.3.1)
131
- tzinfo (0.3.31)
132
- wrong (0.7.0)
133
- diff-lcs (~> 1.1.2)
134
- predicated (~> 0.2.6)
135
- ruby2ruby (>= 2.0.1)
136
- ruby_parser (>= 3.0.1)
137
- sexp_processor (>= 4.0)
138
- xpath (0.1.4)
139
- nokogiri (~> 1.3)
140
-
141
- PLATFORMS
142
- ruby
143
-
144
- DEPENDENCIES
145
- active_mailer!
146
- capybara (>= 0.4.0)
147
- factory_girl
148
- pry
149
- pry-nav
150
- pry-rails
151
- pry-stack_explorer
152
- rails (= 3.2.1)
153
- sqlite3
154
- wrong
data/README DELETED
@@ -1,111 +0,0 @@
1
- ActiveMailer
2
- ============
3
-
4
- Introduction goes here.
5
-
6
- DHH thinks this is a bad idea and he's wrong. Email needs to have somewhere to put the business
7
- logic surrounding it, and the controller is not the place for that.
8
- http://www.robbyonrails.com/articles/2009/11/16/sending-email-controllers-versus-models
9
- http://twitter.com/dhh/status/5769040367
10
- http://twitter.com/dhh/status/5769698185
11
- http://www.loudthinking.com/posts/43-think-of-emails-as-views-delivered-through-smtp
12
-
13
-
14
- Installation
15
- ============
16
-
17
- 1) script/plugin install git://github.com/expectedbehavior/active_mailer.git
18
-
19
- 2) Make the tables for the classes that ActiveMailer uses to store the people you send email to. There's no need to make the models; those are included with the plugin.
20
-
21
- class CreateActiveMailerTables < ActiveRecord::Migration
22
- def self.up
23
- create_table :email_users do |t|
24
- t.string :email_address
25
- t.timestamps
26
- end
27
-
28
- create_table :email_user_associations do |t|
29
- t.references :email_user
30
- t.string :emailable_type
31
- t.integer :emailable_id
32
- t.timestamps
33
- end
34
- end
35
-
36
- def self.down
37
- drop_table :email_users
38
- drop_table :email_user_associations
39
- end
40
- end
41
-
42
-
43
- Basic Usage
44
- ===========
45
-
46
- There's no generator yet (high on the list of things to do). In the mean time, making a new ActiveMailer class can be done like this.
47
-
48
- 1) script/generate model FooEmail # or whatever you want to call your email
49
-
50
- 2) Open up the FooEmail model and change "ActiveRecord::Base" to "ActiveMailer::Base"
51
-
52
- 3) Open up the FooEmail migration and use "create_active_mailer_table" instead of the usual "create_table".
53
-
54
- # sample active mailer migration
55
- class CreateFooEmail < ActiveRecord::Migration
56
- def self.up
57
- create_active_mailer_table :foo_emails do |t|
58
- t.integer :registration_id
59
- t.string :kind
60
- t.timestamps
61
- end
62
- end
63
-
64
- def self.down
65
- drop_table :foo_emails
66
- end
67
- end
68
-
69
- 4) Make the template for your email (in this case called 'foo_email.rb') in app/views/active_mailer/base/default_action_mailer
70
-
71
- At this point, there's no need to do any more. You can send your email by making an object, setting the appropriate details, and calling send.
72
-
73
- > f = FooEmail.new(:subject => "My Awesome Email", :sender => "noreply@example.com", :recipients => "test@example.com")
74
- => #<FooEmail id: nil, blahblahblah>
75
-
76
- > f.send!
77
- => true
78
-
79
-
80
- More Advanced Usage
81
- ===================
82
-
83
- If your email is always going to have the same subject, sender, bcc, etc, then you can always set those things in the mail object. Remember that it's really just an ActiveRecord object, so you can do anything in this class you can do in ActiveRecord. Here's an example of using ActiveRecord associations to make sure there's a user for the email. It also includes setting the subject and sender by default.
84
-
85
- class BeerEmail < ActiveMailer::Base
86
- belongs_to :user
87
-
88
- validates_presence_of :user
89
-
90
- def after_initialize
91
- self.subject = "It's Beer O'Clock"
92
- self.sender = "itstime@beeroclock.com"
93
- end
94
- end
95
-
96
-
97
-
98
- Contributing
99
- ============
100
-
101
- Bugs/Feature
102
- http://www.pivotaltracker.com/projects/14211
103
-
104
- Authors
105
- =======
106
- Matt Gordon
107
-
108
-
109
- Copyright (c) 2009 [Expected Behavior, LLC], released under the MIT license
110
-
111
-
@@ -1,5 +0,0 @@
1
- # Define a bare test case to use with Capybara
2
- class ActiveSupport::IntegrationCase < ActiveSupport::TestCase
3
- include Capybara::DSL
4
- include Rails.application.routes.url_helpers
5
- end