Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ PATH
actionwebpush (0.1.0)
concurrent-ruby (~> 1.1)
net-http-persistent (~> 4.0)
rails (~> 6.0, >= 6.0.0)
rails (>= 6.0)
web-push (~> 3.0)

GEM
Expand Down
Binary file modified actionwebpush-0.1.0.gem
Binary file not shown.
2 changes: 1 addition & 1 deletion actionwebpush.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Gem::Specification.new do |spec|
spec.require_paths = ["lib"]

# Runtime dependencies
spec.add_dependency "rails", "~> 6.0", ">= 6.0.0"
spec.add_dependency "rails", ">= 6.0"
spec.add_dependency "web-push", "~> 3.0"
spec.add_dependency "concurrent-ruby", "~> 1.1"
spec.add_dependency "net-http-persistent", "~> 4.0"
Expand Down
2 changes: 2 additions & 0 deletions app/models/actionwebpush/subscription.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ module ActionWebPush
class Subscription < ActiveRecord::Base
self.table_name = "action_web_push_subscriptions"

belongs_to :user

validates :endpoint, presence: true
validates :p256dh_key, presence: true
validates :auth_key, presence: true
Expand Down
6 changes: 6 additions & 0 deletions lib/actionwebpush.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,10 @@ def config
if defined?(Rails)
require "actionwebpush/railtie"
require "actionwebpush/engine"

module Generators
autoload :InstallGenerator, "actionwebpush/generators/install_generator"
autoload :VapidKeysGenerator, "actionwebpush/generators/vapid_keys_generator"
autoload :CampfireMigrationGenerator, "actionwebpush/generators/campfire_migration_generator"
end
end
12 changes: 10 additions & 2 deletions lib/actionwebpush/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,16 @@ class Railtie < ::Rails::Railtie
end

initializer "action_web_push.set_autoload_paths" do |app|
app.config.autoload_paths << File.expand_path("../../app/models", __dir__)
app.config.autoload_paths << File.expand_path("../../app/controllers", __dir__)
models_path = File.expand_path("../../app/models", __dir__)
controllers_path = File.expand_path("../../app/controllers", __dir__)

unless app.config.autoload_paths.include?(models_path)
app.config.autoload_paths += [models_path]
end

unless app.config.autoload_paths.include?(controllers_path)
app.config.autoload_paths += [controllers_path]
end
end
end
end