2014-10-15から1日間の記事一覧

railstutorial全11章を終えた

railstutorialはRuby on RailsとデファクトスタンダードなGemを使ってTwitter風アプリケーションを作るということを題材に、実際の仕事の開発でも行うGitHub Flowや振る舞い駆動開発をしながら、Webアプリケーション開発を学ぶチュートリアル。 Ruby on Rail…

railstutorial.jp 11章メモ

テーマ has_many throughアソシエーション member, collection ルーティング コレクションとアンパサンドシンボルメソッド名 Ajaxリクエストとレスポンス ユーザ has_many リレーションシップ リレーションシップ has_many ユーザ リレーションシップをリン…

railstutorial.jp 10章メモ

テーマ アソシエーション パーシャル micropostsテーブルの追加 $ rails generate model Micropost content:string user_id:integer $ rake db:migrate $ rake test:prepare やはりテストがこける Failure/Error: let(:user) { FactoryGirl.create(:user) } …

railstutorial.jp 9章メモ

テーマ ユーザーの更新・表示・削除 認証と認可 フレンドリーフォワーディング ページング機能 webブラウザからPATHリクエストができないので、POSTのhiddenパラメータ_methodにpatchが入っている <form accept-charset="UTF-8" action="/users/2" class="edit_user" id="edit_user_2" method="post"> <input name="_method" type="hidden" value="patch" /> Active Recordのnew_record?メソッド Railsは、form…</form>

railstutorial.jp 8章メモ

テーマ ログイン/ログアウト セッションとクッキー nilガード オープンクラス Cucumber セッションコントローラの作成 $ rails generate controller Sessions --no-test-framework $ rails generate integration_test authentication_pages 限定したリソース…

railstutorial.jp 7章メモ

テーマ フォーム paramsでデバッグ <%= debug(params) if Rails.env.development? %> 環境 test development production (Herokuは常にコレ) パラメータを指定して起動 $ rails console test $ rails server --environment production $ rake db:migrate RAI…

railstutorial.jp 6章メモ

テーマ ユーザ登録 モデル バリデーション 認証と権限のモジュールはたくさんあるけどここでは自前で作る Clearance Authlogic Device Cancan モデルは単数形で指定 $ rails generate model User name:string email:string t.timestampsはマジックカラム マ…

railstutorial.jp 5章メモ

テーマ Twitter Bootstrap レイアウト パーシャル ルーティング Asset Pipeline CSS Sass Gem追加 gem 'bootstrap-sass' gem ‘sprockets' config/application.rbに追加 config.assets.precompile += %w(*.png *.jpg *.jpeg *.gif) Bootstrap CSSを追加 app/a…

railstutorial.jp 4章メモ

テーマ 普通のRuby Rails風味のRuby rails console コメント 文字列 式展開 #{first_name}はダブルクォートのなかのみ putsはput string nil.to_s.empty? “".nil? nil.nil? Rubyにおいてifがfalseになるのはfalseとnilのみ if nil then true else false end …

railstutorial.jp 3章メモ

テーマ rails generate erb 振舞駆動開発 (Behavior-Driven Development, BDD) Guard --ski-test-unit は、Test::Unitを使うのではなくRspecを使う為にtestディレクトリを作成しないオプション。 $ rails new sample_app --skip-bundle --skip-test-unit $ b…

railstutorial.jp 2章メモ

テーマ scaffolding MVC rake REST $ mkdir demo_app $ cd demo_app $ rails new . --skip-bundle Gemfileと.envrcは前章のをコピー $ bundle install --path=vendor/bundle --binstubs --without production $ bundle config --delete bin $ rake rails:upd…

railstutorial.jp 1章メモ

テーマ Ruby, Rails, Gem, Bundler Git Heroku $ bundle install --without production $ heroku login $ heroku create Creating xxxxxx-xxx-0000... done, stack is cedar http://xxxxxx-xxx-0000.herokuapp.com/ | git@heroku.com:xxxxxx-xxx-0000.git Gi…