simply_notify 0.2.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cc5b4244495f2ac47c52152ec79694745257fd34
4
- data.tar.gz: d95a4cdb60ea6fcf69f9d39a166bb1eb17931174
3
+ metadata.gz: ac7cf8a36814f3d0135e7e5848c6ece55f99be59
4
+ data.tar.gz: 493aacd2d6a3436ee41da837777c19b30b329809
5
5
  SHA512:
6
- metadata.gz: 57c11f7cfbd7bfe25d08193ba4044c0ac41865a26cc4c1d9634840fcc3e70fa2555cca40fdfb01ffc5b7b959e4aa4f25438d73bbae4b60afa5b12eccda3f4447
7
- data.tar.gz: 4388741dd0e97054231051e609fa0a170bdac345bc0ba4beafa566a448b132c7224a2d13393dbda0a6f5bdfc881fd4f57277f78ac6b09a3dbc9d3cd8598db7b4
6
+ metadata.gz: fd6e2e139f38dfadfa19062fb7da8dcfab6dcdb61bda41e92a99371fc8e93e070bf7412589e46785b13a57ddd9ba1dce3146cce01f77c6903eac894b64356e23
7
+ data.tar.gz: d0db20b3c3805375517d7c953455749921dd72ce007d1f3c500fc4a10cc842f7d7d3c95d9bab3a9820da629fdd0b2c4c0e7f0b62c81b568e64985ea4d0609fa4
data/README.md CHANGED
@@ -22,30 +22,47 @@ Or install it yourself as:
22
22
 
23
23
  ## Usage
24
24
 
25
- Create the model and views using the generator:
25
+ Step 1: Generate mailer and views.
26
26
 
27
27
  rails generate notifier
28
28
 
29
29
 
30
- Place a call in the controller in which you want notifications to be created. For example, if you want each user to be notified when an assignment is created, use a call such as this:
30
+ Step 2: Setup controller where you want then notifications to be created and URL link information.
31
31
 
32
- @users = User.all
32
+ For example, if you want each user to be notified when an assignment is created and a link to the homepage included in the email, use a call such as this (added to app/controllers/assignments_controller.rb)
33
+
34
+ # simply_notify: Most recent ID
35
+ most_recent_id = Assignment.maximum('id')
36
+
37
+ # simply_notify: Notification source URL link
38
+ url = "http://localhost:3000/assignments/postlist?id=#{most_recent_id}"
39
+
40
+ # simply_notify: Deliver email to each user
41
+ # use nil as parameter if you want url link to be the homepage
42
+ # use url as parameter if you want url link to be the source of the notification
43
+ @users = User.all
33
44
  @users.each do |u|
34
- Notifier.new_notification(u.email).deliver_now
45
+ Notifier.new_notification(u.email, url).deliver_now
35
46
  end
36
47
 
37
48
 
38
- Add config SMTP code to appropriate environments. For example, sending emails from a gmail account:
49
+ Step 3: Configure SMTP settings and set homepage as absolute url.
50
+
51
+ For example, sending emails from a gmail account (added to appropriate environments, such as config/environments/development.rb):
39
52
 
40
53
  # SMTP Config
54
+ config.absolute_site_url = 'http://localhost:3000/' #set as your homepage
55
+ config.action_mailer.default_options = {
56
+ from: "YOUR_FROM_EMAIL@gmail.com" #set as your from email
57
+ }
41
58
  config.action_mailer.delivery_method = :smtp
42
59
  config.action_mailer.perform_deliveries = true
43
60
  config.action_mailer.smtp_settings = {
44
61
  address: 'smtp.gmail.com',
45
62
  port: 587,
46
63
  domain: 'gmail.com',
47
- user_name: 'YOUR_USERNAME@gmail.com',
48
- password: 'YOUR_PASSWORD',
64
+ user_name: 'YOUR_USERNAME@gmail.com', #set as your email
65
+ password: 'YOUR_PASSWORD', #set as your password
49
66
  authentication: 'plain',
50
67
  enable_starttls_auto: true }
51
68
 
@@ -18,8 +18,9 @@ class NotifierGenerator < Rails::Generators::Base
18
18
  <body>
19
19
  <h1>Hello</h1>
20
20
  <p>
21
- A new assignment has been posted! Please visit the course website.<br>
22
- Thanks.<br>
21
+ A new assignment has been posted!<br><br>
22
+ Please visit the course website: <%= @url %><br><br>
23
+ Thanks!<br>
23
24
  </p>
24
25
  </body>
25
26
  </html>"
@@ -28,7 +29,9 @@ class NotifierGenerator < Rails::Generators::Base
28
29
  def create_text_view_file
29
30
  create_file "app/views/notifier/new_notification.text.erb",
30
31
  "Hello,
31
- A new assignment has been posted! Please visit the course website.
32
- Thanks."
32
+ A new assignment has been posted!
33
+ Please visit the course website: <%= @url %>.
34
+
35
+ Thanks!"
33
36
  end
34
37
  end
data/lib/simply_notify.rb CHANGED
@@ -2,10 +2,16 @@ require "simply_notify/version"
2
2
  require "action_mailer"
3
3
 
4
4
  class Notifier < ActionMailer::Base
5
- default from: 'brandeisapprenticeship@gmail.com'
6
5
 
7
- def new_notification(recipient)
8
- mail(to: recipient,
9
- subject: 'New Notification')
6
+ def new_notification(recipient, url)
7
+ if url.nil?
8
+ @url = Rails.application.config.absolute_site_url
9
+ mail(to: recipient,
10
+ subject: 'New Notification')
11
+ else
12
+ @url = url
13
+ mail(to: recipient,
14
+ subject: 'New Notification')
15
+ end
10
16
  end
11
17
  end
@@ -1,3 +1,3 @@
1
1
  module SimplyNotify
2
- VERSION = "0.2.4"
2
+ VERSION = "0.2.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simply_notify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Lichten
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-02-29 00:00:00.000000000 Z
11
+ date: 2016-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionmailer