個人アプリ開発スタート
初ブログ・初投稿です
これから個人アプリを開発していく上で行っていく作業だったり
学んだことなんかを記録していきたいと思います。
最初のうちはカリキュラムで学んだ通りに進めていく感じになるのかなー
個人アプリ開発に必要な環境構築①
1.新規アプリ作成
Ruby on Railsのバージョンを変更します。
ターミナル
$ cd ~ # ホームディレクトリに移動 $ gem install rails --version="5.2.3"
ターミナル
$ rbenv rehash
gemの変更を反映します。
ターミナル
$ rails _5.2.3_ new 新規アプリ名 -d mysql
アプリを作りたいディレクトリで実行します。
Gemfileの「mysql2」と「sass-rails」のバージョンを変更します。
Gemfile
source 'https://rubygems.org' git_source(:github) { |repo| "https://github.com/#{repo}.git" } ... (中略) ... # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '~> 5.2.3' # Use mysql as the database for Active Record gem 'mysql2', '0.5.3' # Use Puma as the app server gem 'puma', '~> 3.11' # Use SCSS for stylesheets gem 'sass-rails', '5.0.7' # Use Uglifier as compressor for JavaScript assets gem 'uglifier', '>= 1.3.0' # See https://github.com/rails/execjs#readme for more supported runtimes # gem 'mini_racer', platforms: :ruby ... (中略) ...
Gemfileに以下のコードを追記します。
Gemfile
source 'https://rubygems.org' git_source(:github) { |repo| "https://github.com/#{repo}.git" } ... (中略) ... # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '~> 5.2.3' # Use mysql as the database for Active Record gem 'mysql2', '0.5.2' # Use Puma as the app server gem 'puma', '~> 3.11' # Use SCSS for stylesheets gem 'sass-rails', '5.0.7' # Use Uglifier as compressor for JavaScript assets gem 'uglifier', '>= 1.3.0' # See https://github.com/rails/execjs#readme for more supported runtimes # gem 'mini_racer', platforms: :ruby ... (中略) ... # Windows does not include zoneinfo files, so bundle the tzinfo-data gem gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] gem 'pry-rails' gem 'compass-rails', '3.1.0' gem 'sprockets', '3.7.2'
gemをインストールします。 ターミナル
# Gemfileを元にgemをインストールし、Gemfile.lockを更新する $ bundle update
$ cd アプリ名 $ rails db:create # データベースを作成
2.GitHubで管理
GItHub Desktop から 新規アプリ名のローカルリポジトリを作成します。
左上の「Current Repository」→「Add」→「Add Existing Repository」を選択します。
「Choose...」→「新規アプリ名のフォルダを選択します」→「Add Repository」を選択します。
ローカルリポジトリにある全てのファイルをコミットします。(initial commit)
次にリモートリポジトリを作成します。
「Publish repository」をクリックします。(ローカルリポジトリをプッシュすることでリモートリポジトリを作成)
出てきた画面の中にあるKeep this code privateのチェックを外すと公開設定になります。
今回はここまでにしようと思います。
まとめ
新規アプリを作成して、Gitで管理ができるようになりました。