Sha256: 47b1fb9ae8b0dfa204cd9d96ceceeae40203011f541dfd794b5a983194cd5b75
Contents?: true
Size: 1.61 KB
Versions: 27
Compression:
Stored size: 1.61 KB
Contents
module Netfira::WebConnect::Rails def self.initialize! @config = Configuration.new # Read end-user configuration data, which may include database connection details # This will fail if the end-user hasn't run rails generate web_connect:install begin require Rails.root + 'config/initializers/web_connect' rescue LoadError # If there's no initializer, leave things along if Rails isn't running as a server. # This will give `rails generate` a chance to succeed. return unless caller.grep(/\bconfig\.ru\b/).any? raise 'To complete installation of WebConnect, run `rails generate web_connect:install`' end # Add additional configuration to the web-connect gem Netfira::WebConnect.configure do |c| # Use a blank string as the default table prefix c.db_table_prefix ||= '' # Sharing the host app's DB with no table prefix will cause collisions in the # schema_migrations table, and possibly other tables. raise 'WebConnect cannot share the host application database without a table prefix.' if !c.db && c.db_table_prefix.empty? # Use the default rails logger c.logger = Rails.logger # Use the Rails database connection if none was specified by the end-user c.db ||= Rails.configuration.database_configuration[Rails.env] end # Ensure database is properly migrated, except when running rake tasks if File.basename($0) != 'rake' && Netfira::WebConnect.needs_migration? raise 'WebConnect has pending database migrations. Please run `rake wc:migrate`' end end def self.configure yield @config end end
Version data entries
27 entries across 27 versions & 1 rubygems