def subscribed_by(*resources)
      options = create_options(:subscriptions, resources.extract_options!, [:new, :edit, :update])

      resources.each do |target|
        options[:defaults] = { target_type: target.to_s }.merge(options[:devise_defaults])
        resources_options = options.select { |key, _| [:with_devise, :devise_default_routes, :model, :devise_defaults].exclude? key }
        if options[:with_devise].present? && options[:devise_default_routes].present?
          create_subscription_routes options, resources_options
        else
          self.resources target, only: :none do
            create_subscription_routes options, resources_options
          end
        end
      end

      self
    end
def subscribed_by(*resources)
      options = create_options(:subscriptions, resources.extract_options!, [:new, :edit, :update])

      resources.each do |target|
        options[:defaults] = { target_type: target.to_s }.merge(options[:devise_defaults])
        resources_options = options.select { |key, _| [:with_devise, :devise_default_routes, :model, :devise_defaults].exclude? key }
        if options[:with_devise].present? && options[:devise_default_routes].present?
          create_subscription_routes options, resources_options
        else
          self.resources target, only: :none do
            create_subscription_routes options, resources_options
          end
        end
      end

      self
    end
Includes subscribed_by method for routes, which is responsible to generate all necessary routes for subscriptions of activity_notification.

 When you have an User model configured as a target (e.g. defined acts_as_target),
 you can create as follows in your routes:
   subscribed_by :users
 This method creates the needed routes:
   # Subscription routes
     user_subscriptions                                GET    /users/:user_id/subscriptions(.:format)
       { controller:"activity_notification/subscriptions", action:"index", target_type:"users" }
     user_subscription                                 GET    /users/:user_id/subscriptions/:id(.:format)
       { controller:"activity_notification/subscriptions", action:"show", target_type:"users" }
     open_all_user_subscriptions                       POST   /users/:user_id/subscriptions(.:format)
       { controller:"activity_notification/subscriptions", action:"create", target_type:"users" }
     user_subscription                                 DELETE /users/:user_id/subscriptions/:id(.:format)
       { controller:"activity_notification/subscriptions", action:"destroy", target_type:"users" }
     subscribe_user_subscription                       POST   /users/:user_id/subscriptions/:id/subscribe(.:format)
       { controller:"activity_notification/subscriptions", action:"subscribe", target_type:"users" }
     unsubscribe_user_subscription                     POST   /users/:user_id/subscriptions/:id/unsubscribe(.:format)
       { controller:"activity_notification/subscriptions", action:"unsubscribe", target_type:"users" }
     subscribe_to_email_user_subscription              POST   /users/:user_id/subscriptions/:id/subscribe_to_email(.:format)
       { controller:"activity_notification/subscriptions", action:"subscribe_to_email", target_type:"users" }
     unsubscribe_to_email_user_subscription            POST   /users/:user_id/subscriptions/:id/unsubscribe_to_email(.:format)
       { controller:"activity_notification/subscriptions", action:"unsubscribe_to_email", target_type:"users" }
     subscribe_to_optional_target_user_subscription    POST   /users/:user_id/subscriptions/:id/subscribe_to_optional_target(.:format)
       { controller:"activity_notification/subscriptions", action:"subscribe_to_optional_target", target_type:"users" }
     unsubscribe_to_optional_target_user_subscription  POST   /users/:user_id/subscriptions/:id/unsubscribe_to_optional_target(.:format)
       { controller:"activity_notification/subscriptions", action:"unsubscribe_to_optional_target", target_type:"users" }

 You can also configure notification routes with scope like this:
   scope :myscope, as: :myscope do
     subscribed_by :users, routing_scope: :myscope
   end
 This routing_scope option creates the needed routes with specified scope like this:
   # Subscription routes
     myscope_user_subscriptions                                GET    /myscope/users/:user_id/subscriptions(.:format)
       { controller:"activity_notification/subscriptions", action:"index", target_type:"users", routing_scope: :myscope }
     myscope_user_subscription                                 GET    /myscope/users/:user_id/subscriptions/:id(.:format)
       { controller:"activity_notification/subscriptions", action:"show", target_type:"users", routing_scope: :myscope }
     open_all_myscope_user_subscriptions                       POST   /myscope/users/:user_id/subscriptions(.:format)
       { controller:"activity_notification/subscriptions", action:"create", target_type:"users", routing_scope: :myscope }
     myscope_user_subscription                                 DELETE /myscope/users/:user_id/subscriptions/:id(.:format)
       { controller:"activity_notification/subscriptions", action:"destroy", target_type:"users", routing_scope: :myscope }
     subscribe_myscope_user_subscription                       POST   /myscope/users/:user_id/subscriptions/:id/subscribe(.:format)
       { controller:"activity_notification/subscriptions", action:"subscribe", target_type:"users", routing_scope: :myscope }
     unsubscribe_myscope_user_subscription                     POST   /myscope/users/:user_id/subscriptions/:id/unsubscribe(.:format)
       { controller:"activity_notification/subscriptions", action:"unsubscribe", target_type:"users", routing_scope: :myscope }
     subscribe_to_email_myscope_user_subscription              POST   /myscope/users/:user_id/subscriptions/:id/subscribe_to_email(.:format)
       { controller:"activity_notification/subscriptions", action:"subscribe_to_email", target_type:"users", routing_scope: :myscope }
     unsubscribe_to_email_myscope_user_subscription            POST   /myscope/users/:user_id/subscriptions/:id/unsubscribe_to_email(.:format)
       { controller:"activity_notification/subscriptions", action:"unsubscribe_to_email", target_type:"users", routing_scope: :myscope }
     subscribe_to_optional_target_myscope_user_subscription    POST   /myscope/users/:user_id/subscriptions/:id/subscribe_to_optional_target(.:format)
       { controller:"activity_notification/subscriptions", action:"subscribe_to_optional_target", target_type:"users", routing_scope: :myscope }
     unsubscribe_to_optional_target_myscope_user_subscription  POST   /myscope/users/:user_id/subscriptions/:id/unsubscribe_to_optional_target(.:format)
       { controller:"activity_notification/subscriptions", action:"unsubscribe_to_optional_target", target_type:"users", routing_scope: :myscope }

 When you use devise authentication and you want make subscription targets assciated with devise,
 you can create as follows in your routes:
   subscribed_by :users, with_devise: :users
 This with_devise option creates the needed routes assciated with devise authentication:
   # Subscription with devise routes
     user_subscriptions                                GET    /users/:user_id/subscriptions(.:format)
       { controller:"activity_notification/subscriptions_with_devise", action:"index", target_type:"users", devise_type:"users" }
     user_subscription                                 GET    /users/:user_id/subscriptions/:id(.:format)
       { controller:"activity_notification/subscriptions_with_devise", action:"show", target_type:"users", devise_type:"users" }
     open_all_user_subscriptions                       POST   /users/:user_id/subscriptions(.:format)
       { controller:"activity_notification/subscriptions_with_devise", action:"create", target_type:"users", devise_type:"users" }
     user_subscription                                 DELETE /users/:user_id/subscriptions/:id(.:format)
       { controller:"activity_notification/subscriptions_with_devise", action:"destroy", target_type:"users", devise_type:"users" }
     subscribe_user_subscription                       POST   /users/:user_id/subscriptions/:id/subscribe(.:format)
       { controller:"activity_notification/subscriptions_with_devise", action:"subscribe", target_type:"users", devise_type:"users" }
     unsubscribe_user_subscription                     POST   /users/:user_id/subscriptions/:id/unsubscribe(.:format)
       { controller:"activity_notification/subscriptions_with_devise", action:"unsubscribe", target_type:"users", devise_type:"users" }
     subscribe_to_email_user_subscription              POST   /users/:user_id/subscriptions/:id/subscribe_to_email(.:format)
       { controller:"activity_notification/subscriptions_with_devise", action:"subscribe_to_email", target_type:"users", devise_type:"users" }
     unsubscribe_to_email_user_subscription            POST   /users/:user_id/subscriptions/:id/unsubscribe_to_email(.:format)
       { controller:"activity_notification/subscriptions_with_devise", action:"unsubscribe_to_email", target_type:"users", devise_type:"users" }
     subscribe_to_optional_target_user_subscription    POST   /users/:user_id/subscriptions/:id/subscribe_to_optional_target(.:format)
       { controller:"activity_notification/subscriptions_with_devise", action:"subscribe_to_optional_target", target_type:"users", devise_type:"users" }
     unsubscribe_to_optional_target_user_subscription  POST   /users/:user_id/subscriptions/:id/unsubscribe_to_optional_target(.:format)
       { controller:"activity_notification/subscriptions_with_devise", action:"unsubscribe_to_optional_target", target_type:"users", devise_type:"users" }

 When you use with_devise option and you want to make simple default routes as follows, you can use devise_default_routes option:
   subscribed_by :users, with_devise: :users, devise_default_routes: true
 These with_devise and devise_default_routes options create the needed routes assciated with authenticated devise resource as the default target
   # Subscription with devise routes
     user_subscriptions                                GET    /subscriptions(.:format)
       { controller:"activity_notification/subscriptions_with_devise", action:"index", target_type:"users", devise_type:"users" }
     user_subscription                                 GET    /subscriptions/:id(.:format)
       { controller:"activity_notification/subscriptions_with_devise", action:"show", target_type:"users", devise_type:"users" }
     open_all_user_subscriptions                       POST   /subscriptions(.:format)
       { controller:"activity_notification/subscriptions_with_devise", action:"create", target_type:"users", devise_type:"users" }
     user_subscription                                 DELETE /subscriptions/:id(.:format)
       { controller:"activity_notification/subscriptions_with_devise", action:"destroy", target_type:"users", devise_type:"users" }
     subscribe_user_subscription                       POST   /subscriptions/:id/subscribe(.:format)
       { controller:"activity_notification/subscriptions_with_devise", action:"subscribe", target_type:"users", devise_type:"users" }
     unsubscribe_user_subscription                     POST   /subscriptions/:id/unsubscribe(.:format)
       { controller:"activity_notification/subscriptions_with_devise", action:"unsubscribe", target_type:"users", devise_type:"users" }
     subscribe_to_email_user_subscription              POST   /subscriptions/:id/subscribe_to_email(.:format)
       { controller:"activity_notification/subscriptions_with_devise", action:"subscribe_to_email", target_type:"users", devise_type:"users" }
     unsubscribe_to_email_user_subscription            POST   /subscriptions/:id/unsubscribe_to_email(.:format)
       { controller:"activity_notification/subscriptions_with_devise", action:"unsubscribe_to_email", target_type:"users", devise_type:"users" }
     subscribe_to_optional_target_user_subscription    POST   /subscriptions/:id/subscribe_to_optional_target(.:format)
       { controller:"activity_notification/subscriptions_with_devise", action:"subscribe_to_optional_target", target_type:"users", devise_type:"users" }
     unsubscribe_to_optional_target_user_subscription  POST   /subscriptions/:id/unsubscribe_to_optional_target(.:format)
       { controller:"activity_notification/subscriptions_with_devise", action:"unsubscribe_to_optional_target", target_type:"users", devise_type:"users" }

 @example Define subscribed_by in config/routes.rb
   subscribed_by :users
 @example Define subscribed_by with options
   subscribed_by :users, except: [:index, :show]
 @example Integrated with Devise authentication
   subscribed_by :users, with_devise: :users

 @overload subscribed_by(*resources, *options)
   @param          [Symbol]       resources Resources to notify
   @option options [String]       :routing_scope         (nil)            Routing scope for subscription routes
   @option options [Symbol]       :with_devise           (false)          Devise resources name for devise integration. Devise integration will be enabled by this option.
   @option options [Boolean]      :devise_default_routes (false)          Whether you will create routes as device default routes assciated with authenticated devise resource as the default target
   @option options [String]       :model                 (:subscriptions) Model name of subscriptions
   @option options [String]       :controller            ("activity_notification/subscriptions" | activity_notification/subscriptions_with_devise") :controller option as resources routing
   @option options [Symbol]       :as                    (nil)            :as option as resources routing
   @option options [Array]        :only                  (nil)            :only option as resources routing
   @option options [Array]        :except                (nil)            :except option as resources routing
 @return [ActionDispatch::Routing::Mapper] Routing mapper instance