LoginSignup
3
5

More than 5 years have passed since last update.

Railsアプリの名称を変える方法

Posted at

railsが4系の場合、config/application.rbconfig/initializers/session_store.rbを変えるだけで良い。

config/application.rb
require File.expand_path('../boot', __FILE__)

require 'rails/all'

# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)

module SampleApp ### ここを変える 
  class Application < Rails::Application
    # Settings in config/environments/* take precedence over those specified here.
    # Application configuration should go into files in config/initializers
    # -- all .rb files in that directory are automatically loaded.

    # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
    # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
    # config.time_zone = 'Central Time (US & Canada)'

    # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
    # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
    # config.i18n.default_locale = :de

    # Do not swallow errors in after_commit/after_rollback callbacks.
    config.active_record.raise_in_transactional_callbacks = true
  end
end
config/initializers/session_store.rb
# Be sure to restart your server when you modify this file.

Rails.application.config.session_store :cookie_store, key: '_sample_app_session' ### ここを変える

ただし、config/database.ymlにあるDB名は変更されないため、必要であれば手動で変更する。

3系以下の場合は、renameというgemを使う。

Gemfile
gem 'rename'

bundle installした後に

rails g rename:app_to New-Name

とする。ただし、-_の区別がついていないっぽいことに注意する。名前に-とか_がある場合はrails g rename:app_to New-Nameした後の挙動を見て、必要に応じて手動で直す必要がある。

このgemを使った場合でもDB名は変わらないためconfig/database.ymlを必要に応じて手動で編集する。

参考

3
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
5