久々のRails開発なのだが
- 久々にRailsアプリを作る機会が発生したのだが、Mac内の環境がわからない。
- Rails4が進化してそうで、何だか面倒くさそー。
- サーバに環境作る時にエラーが出たら面倒くさそうー。
- NetBeansでデバッグできないから面倒くさそうー。
何だか、Javaの方がいい気がしてきた。
Javaの環境ではまることはそうそうない。Tomcat入れてデプロイするだけ。ライブラリも安定している。
言語は何でもいいんだけど、今回はRailsにする。
とりあえずrbenvの状況
kenmochi-no-MacBook-Pro:temp junya$ rbenv version 1.9.3-p392 (set by /Users/junya/.rbenv/version) kenmochi-no-MacBook-Pro:temp junya$ rbenv versions system * 1.9.3-p392 (set by /Users/junya/.rbenv/version) 2.0.0-p247
1.9.3をメインで使っていたらしい。そういえば、簡単なWebアプリを作っていたな。。。
いつもそうだけど、RubyもRailsも最新を使う。
と思って、rbenv install -l を実行したが、Ruby 2.1が現れない。。。
ググってみたらrbenvが古いと出てこないとのこと。
以下を実行したが、うまくいかず。
brew update brew upgrade ruby-build
結局ruby-buildを入れ直した。
brew remove --force ruby-build brew install ruby-build
んで、インストール
kenmochi-no-MacBook-Pro:Cellar junya$ rbenv install 2.1.2 Downloading ruby-2.1.2.tar.gz... -> http://dqw8nmjcqpjn7.cloudfront.net/f22a6447811a81f3c808d1c2a5ce3b5f5f0955c68c9a749182feb425589e6635 Installing ruby-2.1.2...
これが長い。。。
が、終了。
kenmochi-no-MacBook-Pro:Cellar junya$ rbenv rehash kenmochi-no-MacBook-Pro:Cellar junya$ rbenv versions system * 1.9.3-p392 (set by /Users/junya/.rbenv/version) 2.0.0-p247 2.1.2
global設定の変更
kenmochi-no-MacBook-Pro:~ junya$ rbenv global 2.1.2 kenmochi-no-MacBook-Pro:~ junya$ rbenv global 2.1.2
Rails4のインストール
ああ面倒くさい。
gem search rails ・・・ rails (4.1.4) ・・・ gem install rails
これも長そうだな。23:49開始。
終了。
kenmochi-no-MacBook-Pro:repos junya$ gem install rails Fetching: i18n-0.6.11.gem (100%) Successfully installed i18n-0.6.11 Fetching: thread_safe-0.3.4.gem (100%) Successfully installed thread_safe-0.3.4 Fetching: tzinfo-1.2.2.gem (100%) Successfully installed tzinfo-1.2.2 Fetching: minitest-5.4.0.gem (100%) Successfully installed minitest-5.4.0 Fetching: activesupport-4.1.4.gem (100%) Successfully installed activesupport-4.1.4 Fetching: rack-1.5.2.gem (100%) Successfully installed rack-1.5.2 Fetching: rack-test-0.6.2.gem (100%) Successfully installed rack-test-0.6.2 Fetching: builder-3.2.2.gem (100%) Successfully installed builder-3.2.2 Fetching: erubis-2.7.0.gem (100%) Successfully installed erubis-2.7.0 Fetching: actionview-4.1.4.gem (100%) Successfully installed actionview-4.1.4 Fetching: actionpack-4.1.4.gem (100%) Successfully installed actionpack-4.1.4 Fetching: activemodel-4.1.4.gem (100%) Successfully installed activemodel-4.1.4 Fetching: arel-5.0.1.20140414130214.gem (100%) Successfully installed arel-5.0.1.20140414130214 Fetching: activerecord-4.1.4.gem (100%) Successfully installed activerecord-4.1.4 Fetching: mime-types-1.25.1.gem (100%) Successfully installed mime-types-1.25.1 Fetching: polyglot-0.3.5.gem (100%) Successfully installed polyglot-0.3.5 Fetching: treetop-1.4.15.gem (100%) Successfully installed treetop-1.4.15 Fetching: mail-2.5.4.gem (100%) Successfully installed mail-2.5.4 Fetching: actionmailer-4.1.4.gem (100%) Successfully installed actionmailer-4.1.4 Fetching: thor-0.19.1.gem (100%) Successfully installed thor-0.19.1 Fetching: railties-4.1.4.gem (100%) Successfully installed railties-4.1.4 Fetching: bundler-1.6.5.gem (100%) Successfully installed bundler-1.6.5 Fetching: hike-1.2.3.gem (100%) Successfully installed hike-1.2.3 Fetching: multi_json-1.10.1.gem (100%) Successfully installed multi_json-1.10.1 Fetching: tilt-1.4.1.gem (100%) Successfully installed tilt-1.4.1 Fetching: sprockets-2.12.1.gem (100%) Successfully installed sprockets-2.12.1 Fetching: sprockets-rails-2.1.3.gem (100%) Successfully installed sprockets-rails-2.1.3 Fetching: rails-4.1.4.gem (100%) Successfully installed rails-4.1.4 Parsing documentation for actionmailer-4.1.4 Installing ri documentation for actionmailer-4.1.4 Parsing documentation for actionpack-4.1.4 Installing ri documentation for actionpack-4.1.4 Parsing documentation for actionview-4.1.4 Installing ri documentation for actionview-4.1.4 Parsing documentation for activemodel-4.1.4 Installing ri documentation for activemodel-4.1.4 Parsing documentation for activerecord-4.1.4 Installing ri documentation for activerecord-4.1.4 Parsing documentation for activesupport-4.1.4 Installing ri documentation for activesupport-4.1.4 Parsing documentation for arel-5.0.1.20140414130214 Installing ri documentation for arel-5.0.1.20140414130214 Parsing documentation for builder-3.2.2 Installing ri documentation for builder-3.2.2 Parsing documentation for bundler-1.6.5 Installing ri documentation for bundler-1.6.5 Parsing documentation for erubis-2.7.0 Installing ri documentation for erubis-2.7.0 Parsing documentation for hike-1.2.3 Installing ri documentation for hike-1.2.3 Parsing documentation for i18n-0.6.11 Installing ri documentation for i18n-0.6.11 Parsing documentation for mail-2.5.4 Installing ri documentation for mail-2.5.4 Parsing documentation for mime-types-1.25.1 Installing ri documentation for mime-types-1.25.1 Parsing documentation for minitest-5.4.0 Installing ri documentation for minitest-5.4.0 Parsing documentation for multi_json-1.10.1 Installing ri documentation for multi_json-1.10.1 Parsing documentation for polyglot-0.3.5 Installing ri documentation for polyglot-0.3.5 Parsing documentation for rack-1.5.2 Installing ri documentation for rack-1.5.2 Parsing documentation for rack-test-0.6.2 Installing ri documentation for rack-test-0.6.2 Parsing documentation for rails-4.1.4 Installing ri documentation for rails-4.1.4 Parsing documentation for railties-4.1.4 Installing ri documentation for railties-4.1.4 Parsing documentation for sprockets-2.12.1 Installing ri documentation for sprockets-2.12.1 Parsing documentation for sprockets-rails-2.1.3 Installing ri documentation for sprockets-rails-2.1.3 Parsing documentation for thor-0.19.1 Installing ri documentation for thor-0.19.1 Parsing documentation for thread_safe-0.3.4 Installing ri documentation for thread_safe-0.3.4 Parsing documentation for tilt-1.4.1 Installing ri documentation for tilt-1.4.1 Parsing documentation for treetop-1.4.15 Installing ri documentation for treetop-1.4.15 Parsing documentation for tzinfo-1.2.2 Installing ri documentation for tzinfo-1.2.2 Done installing documentation for actionmailer, actionpack, actionview, activemodel, activerecord, activesupport, arel, builder, bundler, erubis, hike, i18n, mail, mime-types, minitest, multi_json, polyglot, rack, rack-test, rails, railties, sprockets, sprockets-rails, thor, thread_safe, tilt, treetop, tzinfo after 259 seconds 28 gems installed
念のためrailsのバージョン確認。
kenmochi-no-MacBook-Pro:repos junya$ rbenv rehash kenmochi-no-MacBook-Pro:repos junya$ rails -v Rails 4.1.4
ようやくプロジェクトの作成
kenmochi-no-MacBook-Pro:repos junya$ rails new mobage -d mysql 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/secrets.yml create config/environments create config/environments/development.rb create config/environments/production.rb create config/environments/test.rb create config/initializers create config/initializers/assets.rb create config/initializers/backtrace_silencers.rb create config/initializers/cookies_serializer.rb create config/initializers/filter_parameter_logging.rb create config/initializers/inflections.rb create config/initializers/mime_types.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 test/fixtures create test/fixtures/.keep create test/controllers create test/controllers/.keep create test/mailers create test/mailers/.keep create test/models create test/models/.keep create test/helpers create test/helpers/.keep create test/integration create test/integration/.keep create test/test_helper.rb 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 run bundle install Fetching gem metadata from https://rubygems.org/........... Fetching additional metadata from https://rubygems.org/.. Resolving dependencies... Installing rake 10.3.2 Using i18n 0.6.11 Using json 1.8.1 Using minitest 5.4.0 Using thread_safe 0.3.4 Using tzinfo 1.2.2 Using activesupport 4.1.4 Using builder 3.2.2 Using erubis 2.7.0 Using actionview 4.1.4 Using rack 1.5.2 Using rack-test 0.6.2 Using actionpack 4.1.4 Using mime-types 1.25.1 Using polyglot 0.3.5 Using treetop 1.4.15 Using mail 2.5.4 Using actionmailer 4.1.4 Using activemodel 4.1.4 Using arel 5.0.1.20140414130214 Using activerecord 4.1.4 Using bundler 1.6.5 Installing coffee-script-source 1.7.1 Installing execjs 2.2.1 Installing coffee-script 2.3.0 Using thor 0.19.1 Using railties 4.1.4 Installing coffee-rails 4.0.1 Using hike 1.2.3 Using multi_json 1.10.1 Installing jbuilder 2.1.3 Installing jquery-rails 3.1.1 Installing mysql2 0.3.16 Using tilt 1.4.1 Installing sprockets 2.11.0 Using sprockets-rails 2.1.3 Using rails 4.1.4 Installing rdoc 4.1.1 Installing sass 3.2.19 Installing sass-rails 4.0.3 Installing sdoc 0.4.0 Installing spring 1.1.3 Installing turbolinks 2.2.2 Installing uglifier 2.5.3 Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed. Post-install message from rdoc: Depending on your version of ruby, you may need to install ruby rdoc/ri data: <= 1.8.6 : unsupported = 1.8.7 : gem install rdoc-data; rdoc-data --install = 1.9.1 : gem install rdoc-data; rdoc-data --install >= 1.9.2 : nothing to do! Yay! run bundle exec spring binstub --all * bin/rake: spring inserted * bin/rails: spring inserted
rbenvを2.1.2に設定して、database.ymlを編集して、DB作成して、サーバ起動。
kenmochi-no-MacBook-Pro:repos junya$ cd mobage kenmochi-no-MacBook-Pro:mobage junya$ rbenv local 2.1.2 kenmochi-no-MacBook-Pro:mobage junya$ vi config/database.yml kenmochi-no-MacBook-Pro:mobage junya$ rake db:create kenmochi-no-MacBook-Pro:mobage junya$ rails s
ようやく環境が整った!思っていたほど面倒ではなかった!
今回作るアプリはVPSを管理するもの。最初に作るのは1、2ページくらいのもの。VPSの状態を表示するのと、一斉にコマンドを実行する機能だけ。
それと、高速化するgemとか、いろいろ使ってみたいな、今回は。