Giter VIP home page Giter VIP logo

yay's Introduction

Yay!

このテキストは、Web開発の経験があるけれど、RubyとRailsにはまだ慣れていない方々に向けて作成されたものです。 SmartHRでは、現在多くのプロダクトのバックエンドがRailsによって書かれています。すなわち、RailsのスキルはSmartHRのエンジニアに必須です! しかし、Railsを深く理解するのはとても難しいです。なぜなら、Railsを理解するためにはまずRubyを理解する必要があるからです。 どの言語、どのWAFでも同じですが、そのWAFを使いこなすためには言語の特性を知り、WAFの動きを頭の中で納得することが重要です。

前半パートでは、まずRailsを理解するためのRuby講座があります。そして後半パートでは、現場Railsを題材にしてRailsを理解していきます。 このテキストを終える頃には、あなたはSmartHRのRails戦士です! Yay!

開発環境について

  • Ruby 2.7 以上(2.6などでも動くはずですが、特別な理由がない限り最新のバージョンを利用しましょう)
    • Bundlerは2系のものを準備してください(Ruby 2.7であれば標準でBundler 2系がインストールされています)
  • Rails 6.0 以上

Rubyのインストール方法

新しいRubyが一番良いRubyなのでrbenvを使って新しいRubyを用意しておきましょう

Rubyインストール準備

rbenvをインストールします

Rubyのインストール

インストールできるバージョンを確認しましょう。

% rbenv install -l
2.5.8
2.6.6
2.7.1
jruby-9.2.12.0
maglev-1.0.0
mruby-2.1.1
rbx-5.0
truffleruby-20.1.0

Only latest stable releases for each Ruby implementation are shown.
Use 'rbenv install --list-all' to show all local versions.

rbenvでは、いわゆる普段使うRuby(区別するためにCRubyやMRIなどと呼ばれることもあるよ)以外にJRubyやmrubyなどもインストールできます。 ここでは普通のRubyを使うため、プリフィックスに何も記載されていないものが対象のRubyです。

今回は最新バージョンである2.7.1を利用します。

% rbenv install 2.7.1

ビルドが走るのでコーヒーでも入れてのんびり待ちます。 終わったらインストールしたRubyをデフォルトで使用するRubyに指定します。 (この瞬間だけ任意のバージョンを利用したい!というときはglobalの代わりにshellを使うと良いです)

% rbenv global 2.7.1

rbenv versionsを使うと現在のRubyのインストール・使用状況を確認できます。今回は2.7.1を指定したので、2.7.1に*がついていれば大成功です。 (作業ディレクトリに.ruby-versionなどがあるとそちらを優先するため、思った通りのバージョンにならない場合はそちらも確認しましょう)

% rbenv versions
  system
  2.5.7
  2.6.6
* 2.7.1 (set by /Users/***/.rbenv/version)

最後に、rubyコマンドでも正しいバージョンが利用されているか確認しましょう。

% ruby -v
ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-darwin19]

Railsのインストール方法

Railsを利用するためには、Railsだけでなくnodeなども必要になるためそれらのインストールも必要です。

node/yarnのインストール

インストールしていない人向けです。

https://github.com/nodenv/nodenv#homebrew-on-macos

% brew install nodenv

nodenvがインストールできたら~/.zshrcなどに設定を追記します。

eval "$(nodenv init -)"
export PATH=$HOME/.nodenv/bin:$PATH

その後、ターミナルの再起動などを行い、以下のコマンドでnodeをインストールします。nodeに関してはバージョンの指定はありません。ここではRailsが利用する最低バージョンである10系を指定しますが、12系などでも差し支えはありません。

% nodenv install 10.21.0
% nodenv global 10.21.0
% node -v
v10.21.0

続いてyarnのインストールを行います。こちらもバージョンに関して厳密は指定はないので、普通にyarnが動く状態になっていれば良いです。

https://classic.yarnpkg.com/ja/docs/install#mac-stable

% brew install yarn --ignore-dependencies

ImageMagickのインストール

ActiveStorageなどを利用する場合に必要です。 必要になるときにインストールするでも構いません。

% brew install imagemagick

Railsのインストール

次のコマンドでrailsをインストールしておきます。

% gem i rails --no-doc
Fetching concurrent-ruby-1.1.6.gem
    :
Successfully installed rails-6.0.3.2
40 gems installed
%  rails -v
Rails 6.0.3.2

「現場で使える Ruby on Rails 5速習実践ガイド」向け環境構築

書籍URL : https://book.mynavi.jp/ec/products/detail/id=93905

微妙にバージョンが低いため、別途準備します

Rubyのインストール

Ruby 2.5.1を利用しているので、2.5.1を準備します。 また、Ruby 2.5系ではBundlerが用意されていないため、Bundlerのインストールも行います。

% rbenv install 2.5.1
% rbenv shell 2.5.1
% gem install bundler -v "~> 1.0" --no-doc # bundler 1系をインストールする

Railsのインストール

現場Railsで利用するRailsのバージョンに合わせてるため、以下のようにバージョンを指定してRailsをインストールします(_version_とすることで、任意のバージョンを切り替えることができます)。

% rbenv shell 2.5.1
% gem i rails -v 5.2.1 --no-doc
% rails _5.2.1_ -v
Rails 5.2.1
# rails newするときも `rails _5.2.1_ new sample` などとします

データベースの準備

PostgreSQLが必要なのでインストールしておきます(起動などはしなくてOK)。PostgreSQL自体は次項のDockerを用いますが、gemライブラリのインストールで必要になるため、PostgreSQL自体をインストールだけ実施しておく必要があります。

% brew install postgresql
% postgres -V
postgres (PostgreSQL) 12.2

Dockerの準備

以下を参考にDockerをインストールしてください https://hub.docker.com/editions/community/docker-ce-desktop-mac/

最終的に以下のコマンドが利用可能になればOKです

  • docker
  • docker-compose

LICENSE

このリポジトリは、WTF公衆ライセンスで公開されています。 Yay! is published under the WTFPL.

yay's People

Contributors

diescake avatar kinoppyd avatar sugamasao avatar teruya-himaki avatar tkdn avatar tricknotes avatar yono avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

yay's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.