diff --git a/Gemfile.lock b/Gemfile.lock index 92fafe3..c9d4115 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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 diff --git a/actionwebpush-0.1.0.gem b/actionwebpush-0.1.0.gem index c6d92cb..cac323e 100644 Binary files a/actionwebpush-0.1.0.gem and b/actionwebpush-0.1.0.gem differ diff --git a/actionwebpush.gemspec b/actionwebpush.gemspec index 62c3987..6a4522b 100644 --- a/actionwebpush.gemspec +++ b/actionwebpush.gemspec @@ -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" diff --git a/app/models/actionwebpush/subscription.rb b/app/models/actionwebpush/subscription.rb index c9064aa..54e1377 100644 --- a/app/models/actionwebpush/subscription.rb +++ b/app/models/actionwebpush/subscription.rb @@ -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 diff --git a/lib/actionwebpush.rb b/lib/actionwebpush.rb index baa5439..9d93c87 100644 --- a/lib/actionwebpush.rb +++ b/lib/actionwebpush.rb @@ -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 diff --git a/lib/actionwebpush/railtie.rb b/lib/actionwebpush/railtie.rb index 2df8c52..b1d4738 100644 --- a/lib/actionwebpush/railtie.rb +++ b/lib/actionwebpush/railtie.rb @@ -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 \ No newline at end of file