yutokyokutyo / Summer_Rails

summer_first_app
0 stars 0 forks source link

Rails Tutorial Memo #1

Open yutokyokutyo opened 9 years ago

yutokyokutyo commented 9 years ago

Rails Tutorial

1章

rails new ができない

% rails new summer_first_app
rbenv: rails: command not found

The `rails' command exists in these Ruby versions:
  2.1.1
%  gem install rails --version 4.0.5
Fetching: tzinfo-0.3.44.gem (100%)
Successfully installed tzinfo-0.3.44
Fetching: activesupport-4.0.5.gem (100%)
Successfully installed activesupport-4.0.5
Fetching: builder-3.1.4.gem (100%)
Successfully installed builder-3.1.4
Fetching: rack-1.5.5.gem (100%)
Successfully installed rack-1.5.5
Fetching: rack-test-0.6.3.gem (100%)
Successfully installed rack-test-0.6.3
Fetching: erubis-2.7.0.gem (100%)
Successfully installed erubis-2.7.0
Fetching: actionpack-4.0.5.gem (100%)
Successfully installed actionpack-4.0.5
Fetching: activemodel-4.0.5.gem (100%)
Successfully installed activemodel-4.0.5
Fetching: arel-4.0.2.gem (100%)
Successfully installed arel-4.0.2
Fetching: activerecord-deprecated_finders-1.0.4.gem (100%)
Successfully installed activerecord-deprecated_finders-1.0.4
Fetching: activerecord-4.0.5.gem (100%)
Successfully installed activerecord-4.0.5
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.0.5.gem (100%)
Successfully installed actionmailer-4.0.5
Fetching: thor-0.19.1.gem (100%)
Successfully installed thor-0.19.1
Fetching: railties-4.0.5.gem (100%)
Successfully installed railties-4.0.5
Fetching: hike-1.2.3.gem (100%)
Successfully installed hike-1.2.3
Fetching: sprockets-2.12.4.gem (100%)
Successfully installed sprockets-2.12.4
Fetching: sprockets-rails-2.0.1.gem (100%)
Successfully installed sprockets-rails-2.0.1
Fetching: rails-4.0.5.gem (100%)
Successfully installed rails-4.0.5
Parsing documentation for actionmailer-4.0.5
Installing ri documentation for actionmailer-4.0.5
Parsing documentation for actionpack-4.0.5
Installing ri documentation for actionpack-4.0.5
Parsing documentation for activemodel-4.0.5
Installing ri documentation for activemodel-4.0.5
Parsing documentation for activerecord-4.0.5
Installing ri documentation for activerecord-4.0.5
Parsing documentation for activerecord-deprecated_finders-1.0.4
Installing ri documentation for activerecord-deprecated_finders-1.0.4
Parsing documentation for activesupport-4.0.5
Installing ri documentation for activesupport-4.0.5
Parsing documentation for arel-4.0.2
Installing ri documentation for arel-4.0.2
Parsing documentation for builder-3.1.4
/usr/local/var/rbenv/versions/2.1.5/lib/ruby/2.1.0/rdoc/parser.rb:87: warning: Unsupported encoding : ignored
/usr/local/var/rbenv/versions/2.1.5/lib/ruby/2.1.0/rdoc/parser.rb:87: warning: Unsupported encoding  ignored
/usr/local/var/rbenv/versions/2.1.5/lib/ruby/2.1.0/rdoc/parser.rb:87: warning: Unsupported encoding : ignored
/usr/local/var/rbenv/versions/2.1.5/lib/ruby/2.1.0/rdoc/parser.rb:87: warning: Unsupported encoding  ignored
Installing ri documentation for builder-3.1.4
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 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 polyglot-0.3.5
Installing ri documentation for polyglot-0.3.5
Parsing documentation for rack-1.5.5
Installing ri documentation for rack-1.5.5
Parsing documentation for rack-test-0.6.3
Installing ri documentation for rack-test-0.6.3
Parsing documentation for rails-4.0.5
Installing ri documentation for rails-4.0.5
Parsing documentation for railties-4.0.5
Installing ri documentation for railties-4.0.5
Parsing documentation for sprockets-2.12.4
Installing ri documentation for sprockets-2.12.4
Parsing documentation for sprockets-rails-2.0.1
Installing ri documentation for sprockets-rails-2.0.1
Parsing documentation for thor-0.19.1
Installing ri documentation for thor-0.19.1
Parsing documentation for treetop-1.4.15
Installing ri documentation for treetop-1.4.15
Parsing documentation for tzinfo-0.3.44
Installing ri documentation for tzinfo-0.3.44
Done installing documentation for actionmailer, actionpack, activemodel, activerecord, activerecord-deprecated_finders, activesupport, arel, builder, erubis, hike, mail, mime-types, polyglot, rack, rack-test, rails, railties, sprockets, sprockets-rails, thor, treetop, tzinfo after 382 seconds
22 gems installed
% rails new summer_first_app
      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/environments
      create  config/environments/development.rb
      create  config/environments/production.rb
      create  config/environments/test.rb
      create  config/initializers
      create  config/initializers/backtrace_silencers.rb
      create  config/initializers/filter_parameter_logging.rb
      create  config/initializers/inflections.rb
      create  config/initializers/mime_types.rb
      create  config/initializers/secret_token.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.4.2
Using i18n 0.7.0
Using minitest 4.7.5
Installing multi_json 1.11.2
Using thread_safe 0.3.5
Using tzinfo 0.3.44
Using activesupport 4.0.5
Using builder 3.1.4
Using erubis 2.7.0
Using rack 1.5.5
Using rack-test 0.6.3
Using actionpack 4.0.5
Using mime-types 1.25.1
Using polyglot 0.3.5
Using treetop 1.4.15
Using mail 2.5.4
Using actionmailer 4.0.5
Using activemodel 4.0.5
Using activerecord-deprecated_finders 1.0.4
Using arel 4.0.2
Using activerecord 4.0.5
Using bundler 1.7.11
Installing coffee-script-source 1.9.1.1
Installing execjs 2.5.2
Installing coffee-script 2.4.1
Using thor 0.19.1
Using railties 4.0.5
Installing coffee-rails 4.0.1
Using hike 1.2.3
Installing jbuilder 1.5.3
Installing jquery-rails 3.1.3
Installing json 1.8.3
Using tilt 1.4.1
Using sprockets 2.12.4
Using sprockets-rails 2.0.1
Using rails 4.0.5
Installing rdoc 4.2.0
Installing sass 3.2.19
Installing sass-rails 4.0.5
Installing sdoc 0.4.1
Using sqlite3 1.3.10
Installing turbolinks 2.5.3
Installing uglifier 2.7.1
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!

heroku create できない

% heroku create                                                                                                                                                                                                                                                  (git)-[master]
Your version of git is 2.1.2. Which has serious security vulnerabilities.
More information here: https://blog.heroku.com/archives/2014/12/23/update_your_git_clients_on_windows_and_os_x
 !    You've reached the limit of 5 apps for unverified accounts.
 !    Delete some apps or add a credit card to verify your account.

git の version が古いっぽい

http://kayakuguri.github.io/blog/2014/12/24/git-update-for-mac/

% brew upgrade git                                                                                                                                                                                                                                               (git)-[master]
==> Upgrading 1 outdated package, with result:
git 2.4.4
==> Upgrading git
==> Downloading https://homebrew.bintray.com/bottles/git-2.4.4.yosemite.bottle.tar.gz
######################################################################## 100.0%
==> Pouring git-2.4.4.yosemite.bottle.tar.gz
==> Caveats
The OS X keychain credential helper has been installed to:
  /usr/local/bin/git-credential-osxkeychain

The "contrib" directory has been installed to:
  /usr/local/share/git-core/contrib

Bash completion has been installed to:
  /usr/local/etc/bash_completion.d

zsh completion has been installed to:
  /usr/local/share/zsh/site-functions
==> Summary
🍺  /usr/local/Cellar/git/2.4.4: 1373 files, 32M
% heroku create                                                                                                                                                                                                                                                  (git)-[master]
Enter your Heroku credentials.
Email: k.yuto.cre@gmail.com
Password (typing will be hidden):
 !    You've reached the limit of 5 apps for unverified accounts.
 !    Delete some apps or add a credit card to verify your account.

まだできない!

なるほど。これまえも見たけど heroku のアカウントの数が多いんだぁ。

アカウントを作りなおした。email登録くらいだから簡単!

% heroku create                                                                                                                                                                                                                                                  (git)-[master]
Creating pure-wave-9140... done, stack is cedar-14
https://pure-wave-9140.herokuapp.com/ | https://git.heroku.com/pure-wave-9140.git
Git remote heroku added
% git push heroku master                                                                                                                                                                                                                                         (git)-[master]
Counting objects: 73, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (60/60), done.
Writing objects: 100% (73/73), 16.11 KiB | 0 bytes/s, done.
Total 73 (delta 8), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Ruby app detected
remote: -----> Compiling Ruby/Rails
remote: -----> Using Ruby version: ruby-2.1.5
remote: -----> Installing dependencies using 1.9.7
remote:        Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
remote:        Fetching gem metadata from https://rubygems.org/...........
remote:        Fetching version metadata from https://rubygems.org/...
remote:        Fetching dependency metadata from https://rubygems.org/..
remote:        Using minitest 4.7.5
remote:        Installing i18n 0.7.0
remote:        Installing multi_json 1.11.2
remote:        Installing rake 10.4.2
remote:        Installing thread_safe 0.3.5
remote:        Installing builder 3.1.4
remote:        Installing tzinfo 0.3.44
remote:        Installing erubis 2.7.0
remote:        Installing rack 1.5.5
remote:        Installing mime-types 1.25.1
remote:        Installing polyglot 0.3.5
remote:        Installing activerecord-deprecated_finders 1.0.4
remote:        Installing arel 4.0.2
remote:        Installing coffee-script-source 1.9.1.1
remote:        Installing execjs 2.5.2
remote:        Installing thor 0.19.1
remote:        Installing hike 1.2.3
remote:        Using bundler 1.9.7
remote:        Installing tilt 1.4.1
remote:        Installing rails_serve_static_assets 0.0.4
remote:        Installing rails_stdout_logging 0.0.3
remote:        Installing sass 3.2.19
remote:        Installing activesupport 4.0.5
remote:        Installing rack-test 0.6.3
remote:        Installing treetop 1.4.15
remote:        Installing coffee-script 2.4.1
remote:        Installing uglifier 2.1.1
remote:        Installing sprockets 2.12.4
remote:        Installing rails_12factor 0.0.2
remote:        Installing activemodel 4.0.5
remote:        Installing jbuilder 1.0.2
remote:        Installing actionpack 4.0.5
remote:        Installing mail 2.5.4
remote:        Installing activerecord 4.0.5
remote:        Installing railties 4.0.5
remote:        Installing sprockets-rails 2.0.1
remote:        Installing actionmailer 4.0.5
remote:        Installing coffee-rails 4.0.1
remote:        Installing jquery-rails 3.0.4
remote:        Installing sass-rails 4.0.5
remote:        Installing rails 4.0.5
remote:        Installing turbolinks 1.1.1
remote:        Installing pg 0.15.1
remote:        Installing json 1.8.3
remote:        Installing rdoc 3.12.2
remote:        Installing sdoc 0.3.20
remote:        Bundle complete! 11 Gemfile dependencies, 46 gems now installed.
remote:        Gems in the groups development and test were not installed.
remote:        Bundled gems are installed into ./vendor/bundle.
remote:        Post-install message from rdoc:
remote:        Depending on your version of ruby, you may need to install ruby rdoc/ri data:
remote:        <= 1.8.6 : unsupported
remote:        = 1.8.7 : gem install rdoc-data; rdoc-data --install
remote:        = 1.9.1 : gem install rdoc-data; rdoc-data --install
remote:        >= 1.9.2 : nothing to do! Yay!
remote:        Bundle completed (24.63s)
remote:        Cleaning up the bundler cache.
remote: -----> Writing config/database.yml to read from DATABASE_URL
remote: -----> Preparing app for Rails asset pipeline
remote:        Running: rake assets:precompile
remote:        I, [2015-08-10T05:54:08.536716 #683]  INFO -- : Writing /tmp/build_4ad405c189c92bfcdbe0ad84f16ef71c/public/assets/application-afe52e1d1b66e14d566a4eefe03258e0.js
remote:        I, [2015-08-10T05:54:08.564564 #683]  INFO -- : Writing /tmp/build_4ad405c189c92bfcdbe0ad84f16ef71c/public/assets/application-3e0cccbb54e2038718c2b538a370d24f.css
remote:        Asset precompilation completed (4.71s)
remote:        Cleaning assets
remote:        Running: rake assets:clean
remote:
remote: ###### WARNING:
remote:        No Procfile detected, using the default web server (webrick)
remote:        https://devcenter.heroku.com/articles/ruby-default-web-server
remote:
remote: -----> Discovering process types
remote:        Procfile declares types -> (none)
remote:        Default types for Ruby  -> console, rake, web, worker
remote:
remote: -----> Compressing... done, 28.2MB
remote: -----> Launching... done, v5
remote:        https://pure-wave-9140.herokuapp.com/ deployed to Heroku
remote:
remote: Verifying deploy.... done.
To https://git.heroku.com/pure-wave-9140.git
 * [new branch]      master -> master

単語

yutokyokutyo commented 9 years ago

Rails Tutorial

2章

REST理論そのものはかなり抽象的ですが、RailsアプリケーションにおけるRESTとは、アプリケーションを構成するコンポーネント (ユーザーやマイクロポストなど) を「リソース」としてモデル化することを指します。

HTTPとかCRUDの両方に対応している

単語

その他

気付き

yutokyokutyo commented 9 years ago

test

yutokyokutyo commented 9 years ago

test2