PHPerがRailsデビューしてWebAPIを作りRSpecでテスト書いてCap3/CircleCIでデプロイして分かった事を1ヶ月前の自分に教えたいので、まとめてみたRubyPHPRailsRSpec タイトル長い。すまぬ。PHPerとして約10年近く。Ruby自体は案件によってちょこっとだけ触ったことがある程度。Rails自体を本格的にさわるのは今回が初めて。PHPだとCakePHPを中心にZend/Symfonyなどいくつか。そんな僕が今回、Rails4デビューをして、WebAPIを作り、RSpecでテスト駆動開発風味で、GitHubプルリクベースの、CircleCI経由デプロイをするまでの開発の流れをひと通りやってみて、分かったことがいくつかあったので、それをまとめてみた。過去の自分のために。 注意点としては、今回作ったのはWebサービスではなく、スマホゲーム(ネイティブ)のサー
This copy is for your personal, non-commercial use only. Distribution and use of this material are governed by our Subscriber Agreement and by copyright law. For non-personal use or to order multiple copies, please contact Dow Jones Reprints at 1-800-843-0008 or visit www.djreprints.com. http://jp.wsj.com/article/SB11484601320931144569304582513892156893440.html
GithubにCommitしたら、テストを実行して、EC2のWebサーバに自動的にdeployしてほしいよねーとかねがね思っている方用の手順です。EC2以外はそんなにお金かけたくないなという人もCircleCIならとっつきやすいかもしれません。 継続的イテレーションを導入すべくCIの中でも有名で1コンテナまで無料のCircleCIを導入。 以下作業メモ。 継続的イテレーション(CI)で開発したいよねって思ったら注意点ですが サーバインスタンスは作り直しになる Githubから直接EC2に上げる方法もあるけど意外と情報ないのでS3とCodeDeployも使う CircleCIはCIのツールでプログラムのdeployはCodeDeployが担当するという理屈を理解 というのがあります。私そもそもの理屈がよくわかってなかったです。 ※何か作業中におかしな挙動があった場合はこちらを使って調査してみ
Rails3.2で確認 昨日の Railsで一時的にupdated_atの更新をskip に続いて、 今回は、一時的にbefore_save等のcallbackをskipする方法です。 モデルのskip_callbackメソッドを使用することでskip可能です。 元に戻すにはset_callbackメソッドを使用します。 # サンプル class User < ActiveRecord::Base before_save :hoge def hoge # save前にしたい処理 end end上記のようなUserモデルがあった場合に # before_save :hogeをskip User.skip_callback(:save, :before, :hoge) # 何かしたい処理を記述 user = User.find(1) user.name = 'sample' user.save
FactoryGirlでテストデータを作るとき、before_createなどのコールバックも実行されて、いろいろめんどくさいときがある。 FactoryGirl.define do factory :user do name 'naoty' age 18 after(:build) do User.skip_callback(:create, :before, :hoge_method, :fuga_method) end end end skip_callbackはメソッドごとにスキップするか設定できる。 似たようなものにreset_callbacksがあるけど、これはイベントに設定されてるコールバックメソッドのすべてをスキップする。 after(:build)のところはスキップしたいコールバックのタイミングによって、調整する必要あると思う。 バージョン factory_girl (3
If you have DB columns created_at and updated_at Rails will automatically set those values when you create and update a model object. Is there a way to save the model without touching those columns? I am bringing in some legacy data and I would like to set those values from the corresponding values in the (differently named) legacy data fields. I'm finding when I set them on the model and then sav
Enqueues the job to be performed by the queue adapter. Options :wait - Enqueues the job with the specified delay :wait_until - Enqueues the job at the time specified :queue - Enqueues the job on the specified queue :priority - Enqueues the job with the specified priority Examples my_job_instance.enqueue my_job_instance.enqueue wait: 5.minutes my_job_instance.enqueue queue: :important my_job_instan
Active Jobの導入手順と、Active Job周りのRSpecの書き方をちゃんと理解していなかったので、英語の勉強も兼ねて、 『Active Job Basics — Ruby on Rails Guides』 を読んでみました! 🚌 Active JobとはActive Jobはジョブを宣言し、バックエンドでキュー操作を抽象化して実行するためのフレームワーク。 🗻 ジョブの作成ジョブの作成コマンドはこちら。 $ bin/rails generate job guests_cleanup invoke test_unit create test/jobs/guests_cleanup_job_test.rb create app/jobs/guests_cleanup_job.rb class GuestsCleanupJob < ActiveJob::Base queue_a
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く