LoginSignup
10
11

More than 5 years have passed since last update.

【初めてのRails4】 プロジェクトの作成 rails new

Last updated at Posted at 2014-04-01

Ruby on Railsを触ることになったので、Ruby on Rails チュートリアルを参考にしながら作成記録のメモ

環境

  • CentOS6.4
  • Rails 4.0.4

事前準備に必要なもの

参考にしたサイト

アプリケーションの作成(rails new)

アプリケーションを作成するジェネレーターになります。
プロジェクト名を決めてrailsプロジェクトの最低限のファイルをコマンドで作成しましょう。

まず知っておきたいオプション一覧

Railsドキュメント(railsコマンド(rails))を読めばどんなオプションを存在するのかわかります。

自分の構成としては、下記を想定

  • jqueryはjavascriptゴリゴリ書きたい場合は逆に弊害になるので最初からは入れたくない。(やったことないけど AngularJSBackboneのどちらかで入れたい
  • DBはMYSQL
  • ユニットテストはRspecにしたい

上記を踏まえた上だと下記のコマンドで作るのが理想になります

rails new {プロジェクト名} -d mysql -J -T --skip-gemfile --skip-bundle

ドライランモードでまずは作られるファイルの確認

-pオプションを使用するとドライランモードで出来上がるファイルがわかるので最初は-pつけて出来上がるファイルを確認しましょう

rails new {プロジェクト名} -d mysql -J -T --skip-gemfile --skip-bundle


rails new {プロジェクト名} -d mysql -J -T -p
      create  
      create  README.rdoc
      create  Rakefile
      create  config.ru
      create  .gitignore
      create  Gemfile
      create  app
      create  app/assets/javascripts/application.js
      create  app/assets/stylesheets/application.css
      create  app/controllers/application_controller.rb
      create  app/helpers/application_helper.rb
      create  app/views/layouts/application.html.erb
      create  app/assets/images/.keep
      create  app/mailers/.keep
      create  app/models/.keep
      create  app/controllers/concerns/.keep
      create  app/models/concerns/.keep
      create  bin
      create  bin/bundle
      create  bin/rails
      create  bin/rake
      create  config
      create  config/routes.rb
      create  config/application.rb
      create  config/environment.rb
      create  config/environments
      create  config/environments/development.rb
      create  config/environments/production.rb
      create  config/environments/test.rb
      create  config/initializers
      create  config/initializers/backtrace_silencers.rb
      create  config/initializers/filter_parameter_logging.rb
      create  config/initializers/inflections.rb
      create  config/initializers/mime_types.rb
      create  config/initializers/secret_token.rb
      create  config/initializers/session_store.rb
      create  config/initializers/wrap_parameters.rb
      create  config/locales
      create  config/locales/en.yml
      create  config/boot.rb
      create  config/database.yml
      create  db
      create  db/seeds.rb
      create  lib
      create  lib/tasks
      create  lib/tasks/.keep
      create  lib/assets
      create  lib/assets/.keep
      create  log
      create  log/.keep
      create  public
      create  public/404.html
      create  public/422.html
      create  public/500.html
      create  public/favicon.ico
      create  public/robots.txt
      create  tmp/cache
      create  tmp/cache/assets
      create  vendor/assets/javascripts
      create  vendor/assets/javascripts/.keep
      create  vendor/assets/stylesheets
      create  vendor/assets/stylesheets/.keep

ファイル確認して自分が想定していないものが入っていないか確認しましょう。

プロジェクトの作成

先ほどのコマンドでプロジェクとを作成しましょう。
gemを全然入れていない場合は少し時間かかるかもしれません。

/path/to/hoge
rails new {プロジェクト名} -d mysql -J -T --skip-gemfile --skip-bundle

githubに公開する

コミットしてpushしましょう。
大丈夫です。自分が思っているほど他人は自分のリポジトリをみません!!
事前にプロジェクト名でもリポジトリ名にして作成しておきましょう。

/path/to/hoge/{プロジェクト名}
git init
git add .
git commit -m 'first commit'
git remote add origin https://github.com/{ユーザー名}/{プロジェクト名}.git
git push origin master

これでアプリを作る環境が整いました。

10
11
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
10
11