aboutsummaryrefslogblamecommitdiffstats
path: root/railties/lib/rails_generator/generators/components/session_migration/session_migration_generator.rb
blob: 2e177033a18acb3904db0a28fb38048f9e69a44e (plain) (tree)
1
2
3
4
5
6
7
8
9
10







                                                              

                                                                         

       




                                                                                
   
class SessionMigrationGenerator < Rails::Generator::NamedBase
  def initialize(runtime_args, runtime_options = {})
    runtime_args << 'add_session_table' if runtime_args.empty?
    super
  end

  def manifest
    record do |m|
      m.migration_template 'migration.rb', 'db/migrate',
        :assigns => { :session_table_name => default_session_table_name }
    end
  end

  protected
    def default_session_table_name
      ActiveRecord::Base.pluralize_table_names ? 'session'.pluralize : 'session'
    end
end