po_box 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/po_box/emails_controller.rb +1 -1
- data/app/controllers/po_box/inboxes_controller.rb +1 -1
- data/app/models/concerns/po_box/emailable.rb +3 -3
- data/app/models/po_box/application_record.rb +14 -1
- data/app/models/po_box/email.rb +2 -0
- data/app/models/po_box/inbox.rb +2 -0
- data/app/views/po_box/inboxes/_form.html.erb +5 -0
- data/lib/po_box/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cf5765334ed345c096a6e2432f6775772afc81d3830e9d668e3df23fb782a45f
|
4
|
+
data.tar.gz: bb13be4eaf786de61adf885bb0b3bc0df69c6740f3a94b5067512465c73d656c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 688da89cf7a2dc81c270580a85ebf838aeb9209c14644ccb297dd90faa81743a3631981b43f057a3637e484bb6ea88d1f3b5f19baa249fc3823c8436410854d1
|
7
|
+
data.tar.gz: 9c82e7fdbd57649e2f2e0cdd93d56ffa3532216dcc2bd9df123d3c8f79e5340acfed35acb0c606b3b86cf9dbc7365e9d7c807e774f3ab34328db6a6087d4f181
|
@@ -52,7 +52,7 @@ module PoBox
|
|
52
52
|
def set_inbox
|
53
53
|
@inbox = Inbox.find(params[:inbox_id])
|
54
54
|
rescue ActiveRecord::RecordNotFound
|
55
|
-
redirect_to
|
55
|
+
redirect_to po_box_inboxes_path, notice: "Inbox not found"
|
56
56
|
end
|
57
57
|
|
58
58
|
# Use callbacks to share common setup or constraints between actions.
|
@@ -5,13 +5,13 @@ module PoBox
|
|
5
5
|
included do
|
6
6
|
has_many :inboxes, as: :emailable, class_name: "PoBox::Inbox", dependent: :destroy
|
7
7
|
|
8
|
-
after_create_commit :
|
8
|
+
after_create_commit :generate_inbox
|
9
9
|
|
10
10
|
accepts_nested_attributes_for :inboxes, allow_destroy: true
|
11
11
|
|
12
12
|
private
|
13
13
|
|
14
|
-
def
|
14
|
+
def generate_inbox
|
15
15
|
return if inboxes.any?
|
16
16
|
|
17
17
|
inbox_address = if email.present?
|
@@ -23,7 +23,7 @@ module PoBox
|
|
23
23
|
inbox = inboxes.new
|
24
24
|
loop do
|
25
25
|
inbox.address = inbox_address
|
26
|
-
break unless PoBox.
|
26
|
+
break unless PoBox::Inbox.find_by(address: inbox.address).present?
|
27
27
|
end
|
28
28
|
|
29
29
|
save
|
@@ -1,5 +1,18 @@
|
|
1
1
|
module PoBox
|
2
|
-
class ApplicationRecord < ActiveRecord::Base
|
2
|
+
class ApplicationRecord < ::ActiveRecord::Base
|
3
3
|
self.abstract_class = true
|
4
|
+
|
5
|
+
def self.sort_by_params(column, direction)
|
6
|
+
sortable_column = column.presence_in(sortable_columns) || "created_at"
|
7
|
+
order(sortable_column => direction)
|
8
|
+
end
|
9
|
+
|
10
|
+
# Returns an array of sortable columns on the model
|
11
|
+
# Used with the Sortable controller concern
|
12
|
+
#
|
13
|
+
# Override this method to add/remove sortable columns
|
14
|
+
def self.sortable_columns
|
15
|
+
@sortable_columns ||= columns.map(&:name)
|
16
|
+
end
|
4
17
|
end
|
5
18
|
end
|
data/app/models/po_box/email.rb
CHANGED
data/app/models/po_box/inbox.rb
CHANGED
@@ -2,6 +2,8 @@ module PoBox
|
|
2
2
|
class Inbox < ApplicationRecord
|
3
3
|
belongs_to :emailable, polymorphic: true, class_name: PoBox.emailable_class.to_s
|
4
4
|
|
5
|
+
validates :address, presence: true, uniqueness: true
|
6
|
+
|
5
7
|
has_many :emails, class_name: "PoBox::Email", dependent: :destroy
|
6
8
|
|
7
9
|
define_method PoBox.emailable_class.to_s.underscore do
|
@@ -9,6 +9,11 @@
|
|
9
9
|
</ul>
|
10
10
|
</div>
|
11
11
|
<% end %>
|
12
|
+
<div>
|
13
|
+
<%= form.label "Emailable ID", style: "display: block" %>
|
14
|
+
<%= form.number_field :emailable_id %>
|
15
|
+
<%= form.hidden_field :emailable_type, value: PoBox.emailable_class %>
|
16
|
+
</div>
|
12
17
|
<div>
|
13
18
|
<%= form.label :address, style: "display: block" %>
|
14
19
|
<%= form.text_field :address %>
|
data/lib/po_box/version.rb
CHANGED