Sha256: a39b3712ae989f2fb23b14abcddf7ae8cecccb202d7bf056fb53eb82155f16fa

Contents?: true

Size: 1.06 KB

Versions: 8

Compression:

Stored size: 1.06 KB

Contents

class GlobalSessionGenerator < Rails::Generator::Base
  def initialize(runtime_args, runtime_options = {})
    super

    @app_name   = File.basename(::Rails.root)
    @app_domain = args.shift
    raise ArgumentError, "Must specify DNS domain for global session cookie, e.g. 'example.com'" unless @app_domain
  end

  def manifest
    record do |m|
      
      m.template 'global_session.yml.erb',
                 'config/global_session.yml',
                 :assigns=>{:app_name=>@app_name,
                            :app_domain=>@app_domain}

      puts "*** IMPORTANT - WORK IS REQUIRED ***"
      puts "In order to make use of the global session, you will need to ensure that it"
      puts "is installed to the Rack middleware stack. You can do so by adding an extra"
      puts "line in your environment.rb inside the Rails initializer block, like so:"
      puts
      puts "         Rails::Initializer.run do |config|"
      puts "ADD>>      require 'global_session'"
      puts "ADD>>      GlobalSession::Rails.activate(config)"
      puts "         end"

    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
global_session-1.0.8 rails_generators/global_session/global_session_generator.rb
global_session-1.0.7 rails_generators/global_session/global_session_generator.rb
global_session-1.0.6 rails_generators/global_session/global_session_generator.rb
global_session-1.0.5 rails_generators/global_session/global_session_generator.rb
global_session-1.0.4 rails_generators/global_session/global_session_generator.rb
global_session-1.0.3 rails_generators/global_session/global_session_generator.rb
global_session-1.0.2 rails_generators/global_session/global_session_generator.rb
global_session-1.0.0 rails_generators/global_session/global_session_generator.rb