LoginSignup
1
4

More than 5 years have passed since last update.

Ruby on Railsで0からアプリケーションを作るときのセッティング【備忘録】

Last updated at Posted at 2018-08-15

毎度Ruby on Railsでrails newコマンドを叩く際にrubyやrailsバージョンに迷ったり、必要な設定に苦慮することが多々あったので、この際にまとめてみます。

好きなrailsのバージョンをインストール

$ gem install rails --version="5.2.0"

gemの変更を反映する

$ rbenv rehash

反映されたか確認

$ rails -v

アプリケーションを作成

ターミナル
$ rails _5.2.0_ new rails_app -d mysql  #railsのバージョンとデータベースを指定
$ cd rails_app  #rails_appディレクトリに移動

データベースを作成

$ bundle exec rake db:create # データベースを作成

不要なファイル作成を防ぐ

config/application.rb
# 省略
module RailApp
  class Application < Rails::Application
    # 省略
    config.generators do |g|
      g.stylesheets false
      g.javascripts false
      g.helper false
      g.test_framework false
    end
  end
end

gitの設定

gitの初期化

$ git init

ローカルリポジトリにコミット

ステージングエリアへ登録
$ git add .

コミット
$ git commit -m "Initial commit"

githubに登録

リモートリポジトリに追加
$ git remote add origin git@github.com:ユーザ名/アプリケーション名.git

リモートリポジトリにプッシュ
$ git push -u origin master

さあ、ここからはブランチを切って作業を開始していきましょう!

stylesheetの用意

下記を参考にする

HTMLとCSSクラスでよく使う命名について
https://qiita.com/pugiemonn/items/eaa597b79fe59a1f1506

Railsのプロジェクトリニューアルの機会にHTML/CSSのコーディング規約を作ってみた
https://qiita.com/soyanchu/items/dd99fe2b3d08eb7128c7

1
4
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
1
4