LoginSignup
0
0

More than 3 years have passed since last update.

Rails newについて調べたメモ

Posted at

概要

プログラミングを始めて早1ヶ月。ずっと脳死でrails newしておりました。
脳死は大好きなのですがこれはよくないとふと思い、上記コマンド調べてみようというメモです。

具体的にはrails newについて調べたことを記載するだけです。

環境

$ rails -v       
Rails 6.0.3.1

とりあえずコマンド実行結果

$ rails new -h

Usage:
  rails new APP_PATH [options]

Options:
      [--skip-namespace], [--no-skip-namespace]              # Skip namespace (affects only isolated applications)
  -r, [--ruby=PATH]                                          # Path to the Ruby binary of your choice
                                                             # Default: /Users/masuyamayo/.rbenv/versions/2.6.5/bin/ruby
  -m, [--template=TEMPLATE]                                  # Path to some application template (can be a filesystem path or URL)
  -d, [--database=DATABASE]                                  # Preconfigure for selected database (options: mysql/postgresql/sqlite3/oracle/frontbase/ibm_db/sqlserver/jdbcmysql/jdbcsqlite3/jdbcpostgresql/jdbc)
                                                             # Default: sqlite3
      [--skip-gemfile], [--no-skip-gemfile]                  # Don't create a Gemfile
  -G, [--skip-git], [--no-skip-git]                          # Skip .gitignore file
      [--skip-keeps], [--no-skip-keeps]                      # Skip source control .keep files
  -M, [--skip-action-mailer], [--no-skip-action-mailer]      # Skip Action Mailer files
      [--skip-action-mailbox], [--no-skip-action-mailbox]    # Skip Action Mailbox gem
      [--skip-action-text], [--no-skip-action-text]          # Skip Action Text gem
  -O, [--skip-active-record], [--no-skip-active-record]      # Skip Active Record files
      [--skip-active-storage], [--no-skip-active-storage]    # Skip Active Storage files
  -P, [--skip-puma], [--no-skip-puma]                        # Skip Puma related files
  -C, [--skip-action-cable], [--no-skip-action-cable]        # Skip Action Cable files
  -S, [--skip-sprockets], [--no-skip-sprockets]              # Skip Sprockets files
      [--skip-spring], [--no-skip-spring]                    # Don't install Spring application preloader
      [--skip-listen], [--no-skip-listen]                    # Don't generate configuration that depends on the listen gem
  -J, [--skip-javascript], [--no-skip-javascript]            # Skip JavaScript files
      [--skip-turbolinks], [--no-skip-turbolinks]            # Skip turbolinks gem
  -T, [--skip-test], [--no-skip-test]                        # Skip test files
      [--skip-system-test], [--no-skip-system-test]          # Skip system test files
      [--skip-bootsnap], [--no-skip-bootsnap]                # Skip bootsnap gem
      [--dev], [--no-dev]                                    # Setup the application with Gemfile pointing to your Rails checkout
      [--edge], [--no-edge]                                  # Setup the application with Gemfile pointing to Rails repository
      [--rc=RC]                                              # Path to file containing extra configuration options for rails command
      [--no-rc], [--no-no-rc]                                # Skip loading of extra configuration options from .railsrc file
      [--api], [--no-api]                                    # Preconfigure smaller stack for API only apps
  -B, [--skip-bundle], [--no-skip-bundle]                    # Don't run bundle install
  --webpacker, [--webpack=WEBPACK]                           # Preconfigure Webpack with a particular framework (options: react, vue, angular, elm, stimulus)
      [--skip-webpack-install], [--no-skip-webpack-install]  # Don't run Webpack install

Runtime options:
  -f, [--force]                    # Overwrite files that already exist
  -p, [--pretend], [--no-pretend]  # Run but do not make any changes
  -q, [--quiet], [--no-quiet]      # Suppress status output
  -s, [--skip], [--no-skip]        # Skip files that already exist

Rails options:
  -h, [--help], [--no-help]        # Show this help message and quit
  -v, [--version], [--no-version]  # Show Rails version number and quit

Description:
    The 'rails new' command creates a new Rails application with a default
    directory structure and configuration at the path you specify.

    You can specify extra command-line arguments to be used every time
    'rails new' runs in the .railsrc configuration file in your home directory.

    Note that the arguments specified in the .railsrc file don't affect the
    defaults values shown above in this help message.

Example:
    rails new ~/Code/Ruby/weblog

    This generates a skeletal Rails installation in ~/Code/Ruby/weblog.

おじさん英語弱いんだよな。。。
とりあえずわかるとこだけメモ。

Usage

Usage:
  rails new APP_PATH [options]

意味

新規railsプロジェクトを作成するコマンド。
Usageは使用法って意味。

APP_PASSでアプリのディレクトリを指定する。

使用例

$ rails new hoge

と入力するとカレントディレクトリ配下にhogeという名前でrailsアプリが作成される。

バージョンはインストールされているrailsの中で最新バージョンが選ばれるっぽい。

ちなみに相対パスや絶対パスで指定も可能。

相対パス

$ rails new hoge/hoge

絶対パス

$ rails new /hoge/hoge

ちなみに下記のようにバージョン指定してインストールすることも可能。

rails _6.0.0_ new hogehoge

なお、指定できるバージョンはインストールされているもののみ。
インストールされてるバージョンはgem list railsでわかる。

$ gem list rails

*** LOCAL GEMS ***

rails (6.0.3.1, 6.0.2.1, 6.0.0, 5.2.4.3, 5.2.1) #インストールしているrailsのバージョン

上記のコマンドで指定してもバージョンが合わない時がある。
それはデフォルトでGemfileに

 gem 'rails', '~> 6.0.0'

みたいな指定されている為。

~> はマイナーバージョンの部分に相当するアップデート済みのgemをインストールするということで6.1はインストールしないけど、6.0.2とか6.0.3とかはインストールされちゃうらしい。

なのでマイナーバージョンまで指定する場合はGemfileを書き換えてbundle updateするか最初にbundle installをスキップしてインストールするといい。

◆参考
https://techtechmedia.com/rails-new-version-error/)

最後に

ほんとはオプションとかも調べる予定だったけど、インターネットの限界を感じて断念。
少しづついろんなコマンド試して学んだりしていかないとなあ。

0
0
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
0
0