How to install Rails4
Previously on this blog, I installed Ruby 2.2.
The Ruby is running on the rbenv.
Upgrade Ruby from version 2.0 to 2.2 on Mac - Another Japan in the World
And that is because I will install Rails4.
This time, I will install Rails4.
Default ruby version is 2.0.
$ cd $ ruby -v ruby 2.0.0p481 (2014-05-08 revision 45883) [x86_64-darwin13.2.0]
Move to the directory to install rails4.
And set the ruby which is used under the this directory.
$ cd ~/git/test-rails4/ $ rbenv local 2.2.3 $ cat .ruby-version 2.2.3 $ rbenv version 2.2.3 (set by RBENV_VERSION environment variable) $ ruby -v ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin13]
Install Bundler.
Bundler is like a Carton in Perl, and a Composer in PHP.
$ rbenv exec gem list *** LOCAL GEMS *** bigdecimal (1.2.6) io-console (0.4.3) json (1.8.1) minitest (5.4.3) power_assert (0.2.2) psych (2.0.8) rake (10.4.2) rdoc (4.2.0) test-unit (3.0.8) $ rbenv exec gem install bundler Fetching: bundler-1.10.6.gem (100%) Successfully installed bundler-1.10.6 Parsing documentation for bundler-1.10.6 Installing ri documentation for bundler-1.10.6 Done installing documentation for bundler after 4 seconds 1 gem installed $ rbenv exec gem list *** LOCAL GEMS *** bigdecimal (1.2.6) bundler (1.10.6) io-console (0.4.3) json (1.8.1) minitest (5.4.3) power_assert (0.2.2) psych (2.0.8) rake (10.4.2) rdoc (4.2.0) test-unit (3.0.8)
Create Gemfile.
$ rbenv exec bundle init Writing new Gemfile to $HOME/git/test-rails4/Gemfile
Edit Gemfile to install Rails 4.2.4.
$ vi Gemfile source "https://rubygems.org" gem "rails", "4.2.4"
Install gem modules under the vendor/bundle.
$ rbenv exec bundle install --path vendor/bundle $ ls vendor/bundle/ruby/2.2.0/ | cat bin/ build_info/ cache/ doc/ extensions/ gems/ specifications/
Check gem modules which are installed by Bundler.
$ rbenv exec bundle list * actionmailer (4.2.4) ... * rails (4.2.4) ... * tzinfo (1.2.2)
Create rails project "project-foo" with SQLite. SQLLite is default DB.
$ rbenv exec bundle exec rails new project-foo --skip-bundle create create README.rdoc ... create vendor/assets/stylesheets create vendor/assets/stylesheets/.keep
$ ls project-foo/ | cat .gitignore Gemfile README.rdoc Rakefile app/ bin/ config/ config.ru db/ lib/ log/ public/ test/ tmp/ vendor/
Move to Rails project directory. and Install gem modules which are defined in Gemfile.
$ cd project-foo/ $ rbenv exec bundle install --path vendor/bundle
Finally, run Rails server in development.
$ rbenv exec bundle exec rails server => Booting WEBrick => Rails 4.2.4 application starting in development on http://localhost:3000 => Run `rails server -h` for more startup options => Ctrl-C to shutdown server [2015-09-08 02:12:09] INFO WEBrick 1.3.1 [2015-09-08 02:12:09] INFO ruby 2.2.3 (2015-08-18) [x86_64-darwin13] [2015-09-08 02:12:09] INFO WEBrick::HTTPServer#start: pid=51090 port=3000
Then access to http://localhost:3000, and check the page.
Used code is here in github.
junaruga/test-rails4 · GitHub
I referred this Japanese web site.
http://qiita.com/egopro/items/aba12261c053eecd6d19
That's all.